mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
fix: use block hash from the query to get bor tx
This commit is contained in:
parent
436ed45548
commit
e25a5dfb8a
5 changed files with 30 additions and 2 deletions
|
|
@ -146,7 +146,25 @@ func DeleteBorReceipt(db ethdb.KeyValueWriter, hash common.Hash, number uint64)
|
|||
}
|
||||
}
|
||||
|
||||
// ReadBorTransaction retrieves a specific bor (fake) transaction, along with
|
||||
// ReadBorTransactionWithBlockHash retrieves a specific bor (fake) transaction by tx hash and block hash, along with
|
||||
// its added positional metadata.
|
||||
func ReadBorTransactionWithBlockHash(db ethdb.Reader, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) {
|
||||
blockNumber := ReadBorTxLookupEntry(db, txHash)
|
||||
if blockNumber == nil {
|
||||
return nil, common.Hash{}, 0, 0
|
||||
}
|
||||
|
||||
body := ReadBody(db, blockHash, *blockNumber)
|
||||
if body == nil {
|
||||
log.Error("Transaction referenced missing", "number", blockNumber, "hash", blockHash)
|
||||
return nil, common.Hash{}, 0, 0
|
||||
}
|
||||
|
||||
// fetch receipt and return it
|
||||
return types.NewBorTransaction(), blockHash, *blockNumber, uint64(len(body.Transactions))
|
||||
}
|
||||
|
||||
// ReadBorTransaction retrieves a specific bor (fake) transaction by hash, along with
|
||||
// its added positional metadata.
|
||||
func ReadBorTransaction(db ethdb.Reader, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) {
|
||||
blockNumber := ReadBorTxLookupEntry(db, hash)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ func (b *EthAPIBackend) GetBorBlockTransaction(ctx context.Context, hash common.
|
|||
return tx, blockHash, blockNumber, index, nil
|
||||
}
|
||||
|
||||
func (b *EthAPIBackend) GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) {
|
||||
tx, blockHash, blockNumber, index := rawdb.ReadBorTransactionWithBlockHash(b.eth.ChainDb(), txHash, blockHash)
|
||||
return tx, blockHash, blockNumber, index, nil
|
||||
}
|
||||
|
||||
// SubscribeStateSyncEvent subscribes to state sync event
|
||||
func (b *EthAPIBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription {
|
||||
return b.eth.BlockChain().SubscribeStateSyncEvent(ch)
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ type Backend interface {
|
|||
GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error)
|
||||
GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]*types.Log, error)
|
||||
GetBorBlockTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
|
||||
GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
|
||||
|
||||
ChainConfig() *params.ChainConfig
|
||||
Engine() consensus.Engine
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func (s *PublicBlockChainAPI) GetBorBlockReceipt(ctx context.Context, hash commo
|
|||
func (s *PublicBlockChainAPI) appendRPCMarshalBorTransaction(ctx context.Context, block *types.Block, fields map[string]interface{}, fullTx bool) map[string]interface{} {
|
||||
if block != nil {
|
||||
txHash := types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash()))
|
||||
borTx, blockHash, blockNumber, txIndex, _ := s.b.GetBorBlockTransaction(ctx, txHash)
|
||||
borTx, blockHash, blockNumber, txIndex, _ := s.b.GetBorBlockTransactionWithBlockHash(ctx, txHash, block.Hash())
|
||||
if borTx != nil {
|
||||
formattedTxs := fields["transactions"].([]interface{})
|
||||
if fullTx {
|
||||
|
|
|
|||
|
|
@ -324,3 +324,7 @@ func (b *LesApiBackend) GetBorBlockLogs(ctx context.Context, hash common.Hash) (
|
|||
func (b *LesApiBackend) GetBorBlockTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) {
|
||||
return nil, common.Hash{}, 0, 0, errors.New("Not implemented")
|
||||
}
|
||||
|
||||
func (b *LesApiBackend) GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) {
|
||||
return nil, common.Hash{}, 0, 0, errors.New("Not implemented")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue