mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Fix GetTransaction
This commit is contained in:
parent
83f9d4da6d
commit
eeb08cca19
1 changed files with 12 additions and 0 deletions
|
|
@ -255,6 +255,18 @@ func GetTxLookupEntry(db ethdb.Database, hash common.Hash) (common.Hash, uint64,
|
||||||
// GetTransaction retrieves a specific transaction from the database, along with
|
// GetTransaction retrieves a specific transaction from the database, along with
|
||||||
// its added positional metadata.
|
// its added positional metadata.
|
||||||
func GetTransaction(db ethdb.Database, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) {
|
func GetTransaction(db ethdb.Database, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) {
|
||||||
|
// Retrieve the lookup metadata and resolve the transaction from the body
|
||||||
|
blockHash, blockNumber, txIndex := GetTxLookupEntry(db, hash)
|
||||||
|
|
||||||
|
if blockHash != (common.Hash{}) {
|
||||||
|
body := GetBody(db, blockHash, blockNumber)
|
||||||
|
if body == nil || len(body.Transactions) <= int(txIndex) {
|
||||||
|
glog.V(logger.Error).Infof("Transaction referenced missing", "number", blockNumber, "hash", blockHash, "index", txIndex)
|
||||||
|
return nil, common.Hash{}, 0, 0
|
||||||
|
}
|
||||||
|
return body.Transactions[txIndex], blockHash, blockNumber, txIndex
|
||||||
|
}
|
||||||
|
// Old transaction representation, load the transaction and it's metadata separately
|
||||||
// Retrieve the transaction itself from the database
|
// Retrieve the transaction itself from the database
|
||||||
data, _ := db.Get(hash.Bytes())
|
data, _ := db.Get(hash.Bytes())
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue