mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Update api.go
This commit is contained in:
parent
31d5d82ce5
commit
92c9f57227
1 changed files with 21 additions and 16 deletions
|
|
@ -1638,6 +1638,19 @@ func (api *TransactionAPI) currentBlobSidecarVersion() byte {
|
||||||
return types.BlobSidecarVersion0
|
return types.BlobSidecarVersion0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convertLegacyBlobSidecar upgrades legacy blob sidecar proofs to the currently
|
||||||
|
// expected version if needed. It returns the (possibly updated) transaction.
|
||||||
|
func convertLegacyBlobSidecar(tx *types.Transaction, expectedVersion byte) (*types.Transaction, error) {
|
||||||
|
sc := tx.BlobTxSidecar()
|
||||||
|
if sc == nil || sc.Version != types.BlobSidecarVersion0 || expectedVersion != types.BlobSidecarVersion1 {
|
||||||
|
return tx, nil
|
||||||
|
}
|
||||||
|
if err := sc.ToV1(); err != nil {
|
||||||
|
return nil, fmt.Errorf("blob sidecar conversion failed: %v", err)
|
||||||
|
}
|
||||||
|
return tx.WithBlobTxSidecar(sc), 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) {
|
||||||
|
|
@ -1648,14 +1661,10 @@ 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 {
|
if updated, err := convertLegacyBlobSidecar(tx, api.currentBlobSidecarVersion()); err != nil {
|
||||||
exp := api.currentBlobSidecarVersion()
|
return common.Hash{}, err
|
||||||
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
|
} else {
|
||||||
if err := sc.ToV1(); err != nil {
|
tx = updated
|
||||||
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)
|
||||||
|
|
@ -1671,14 +1680,10 @@ 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 {
|
if updated, err := convertLegacyBlobSidecar(tx, api.currentBlobSidecarVersion()); err != nil {
|
||||||
exp := api.currentBlobSidecarVersion()
|
return nil, err
|
||||||
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
|
} else {
|
||||||
if err := sc.ToV1(); err != nil {
|
tx = updated
|
||||||
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