always add eth hash lookup key

pull/3566/head
Rongjian Lan 4 years ago
parent 3dcc92cee5
commit dbcebfaca5
  1. 10
      core/rawdb/accessors_indexes.go
  2. 14
      rpc/eth/types.go

@ -58,12 +58,10 @@ func WriteBlockTxLookUpEntries(db DatabaseWriter, block *types.Block) error {
if err := db.Put(key, val); err != nil {
return err
}
if tx.IsEthCompatible() {
// Also put a lookup entry for eth transaction's hash
key := txLookupKey(tx.HashByType())
if err := db.Put(key, val); err != nil {
return err
}
// Also put a lookup entry for eth transaction's hash
key = txLookupKey(tx.ConvertToEth().Hash())
if err := db.Put(key, val); err != nil {
return err
}
}
return nil

@ -214,8 +214,8 @@ func NewBlockWithFullTx(b *types.Block, blockArgs *rpc_common.BlockArgs, leader
Transactions: []*Transaction{},
}
for _, tx := range b.Transactions() {
fmtTx, err := NewTransactionFromBlockHash(b, tx.Hash())
for idx, _ := range b.Transactions() {
fmtTx, err := NewTransactionFromBlockIndex(b, uint64(idx))
if err != nil {
return nil, err
}
@ -229,16 +229,6 @@ func NewBlockWithFullTx(b *types.Block, blockArgs *rpc_common.BlockArgs, leader
return blkWithTxs, nil
}
// NewTransactionFromBlockHash returns a transaction that will serialize to the RPC representation.
func NewTransactionFromBlockHash(b *types.Block, hash common.Hash) (*Transaction, error) {
for idx, tx := range b.Transactions() {
if tx.Hash() == hash {
return NewTransactionFromBlockIndex(b, uint64(idx))
}
}
return nil, fmt.Errorf("tx %v not found in block %v", hash, b.Hash().String())
}
// NewTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.
func NewTransactionFromBlockIndex(b *types.Block, index uint64) (*Transaction, error) {
txs := b.Transactions()

Loading…
Cancel
Save