mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 19:56:44 +00:00
Update api.go
This commit is contained in:
parent
c2595381bf
commit
64930c2e6b
1 changed files with 25 additions and 19 deletions
|
|
@ -612,15 +612,17 @@ func (api *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txs := block.Transactions()
|
txs := block.Transactions()
|
||||||
if len(txs) != len(receipts) {
|
txCount := len(txs)
|
||||||
return nil, fmt.Errorf("receipts length mismatch: %d vs %d", len(txs), len(receipts))
|
receiptCount := len(receipts)
|
||||||
|
if txCount != receiptCount {
|
||||||
|
return nil, fmt.Errorf("receipts length mismatch: %d vs %d", txCount, receiptCount)
|
||||||
}
|
}
|
||||||
// Derive the sender.
|
// Derive the sender.
|
||||||
signer := types.MakeSigner(api.b.ChainConfig(), block.Number(), block.Time())
|
signer := types.MakeSigner(api.b.ChainConfig(), block.Number(), block.Time())
|
||||||
|
|
||||||
result := make([]map[string]interface{}, len(receipts))
|
result := make([]map[string]interface{}, len(receipts))
|
||||||
for i, receipt := range receipts {
|
for i, receipt := range receipts {
|
||||||
result[i] = MarshalReceipt(receipt, block.Hash(), block.NumberU64(), signer, txs[i], i)
|
result := make([]map[string]interface{}, receiptCount)
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
@ -1636,6 +1638,20 @@ func (api *TransactionAPI) currentBlobSidecarVersion() byte {
|
||||||
return types.BlobSidecarVersion0
|
return types.BlobSidecarVersion0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *TransactionAPI) convertLegacyBlobSidecar(tx *types.Transaction) (*types.Transaction, error) {
|
||||||
|
if sc := tx.BlobTxSidecar(); sc != nil {
|
||||||
|
exp := api.currentBlobSidecarVersion()
|
||||||
|
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
|
||||||
|
if err := sc.ToV1(); err != nil {
|
||||||
|
return nil, fmt.Errorf("blob sidecar conversion failed: %v", err)
|
||||||
|
}
|
||||||
|
tx = tx.WithBlobTxSidecar(sc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SendRawTransaction will add the signed transaction to the transaction pool.
|
// SendRawTransaction will add the signed transaction to the transaction pool.
|
||||||
// The sender is responsible for signing the transaction and using the correct nonce.
|
// The sender is responsible for signing the transaction and using the correct nonce.
|
||||||
func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) {
|
func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) {
|
||||||
|
|
@ -1646,14 +1662,9 @@ func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil
|
||||||
|
|
||||||
// Convert legacy blob transaction proofs.
|
// Convert legacy blob transaction proofs.
|
||||||
// TODO: remove in go-ethereum v1.17.x
|
// TODO: remove in go-ethereum v1.17.x
|
||||||
if sc := tx.BlobTxSidecar(); sc != nil {
|
tx, err := api.convertLegacyBlobSidecar(tx)
|
||||||
exp := api.currentBlobSidecarVersion()
|
if err != nil {
|
||||||
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
|
return common.Hash{}, err
|
||||||
if err := sc.ToV1(); err != nil {
|
|
||||||
return common.Hash{}, fmt.Errorf("blob sidecar conversion failed: %v", err)
|
|
||||||
}
|
|
||||||
tx = tx.WithBlobTxSidecar(sc)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SubmitTransaction(ctx, api.b, tx)
|
return SubmitTransaction(ctx, api.b, tx)
|
||||||
|
|
@ -1669,14 +1680,9 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
|
||||||
|
|
||||||
// Convert legacy blob transaction proofs.
|
// Convert legacy blob transaction proofs.
|
||||||
// TODO: remove in go-ethereum v1.17.x
|
// TODO: remove in go-ethereum v1.17.x
|
||||||
if sc := tx.BlobTxSidecar(); sc != nil {
|
tx, err := api.convertLegacyBlobSidecar(tx)
|
||||||
exp := api.currentBlobSidecarVersion()
|
if err != nil {
|
||||||
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
|
return nil, err
|
||||||
if err := sc.ToV1(); err != nil {
|
|
||||||
return nil, fmt.Errorf("blob sidecar conversion failed: %v", err)
|
|
||||||
}
|
|
||||||
tx = tx.WithBlobTxSidecar(sc)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ch := make(chan core.ChainEvent, 128)
|
ch := make(chan core.ChainEvent, 128)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue