aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-04-01 18:14:35 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-04-01 18:14:35 +0800
commit86ba7432a965d9469ce1b4ccc2397ed2e08c9a3c (patch)
tree903183222dc26998d44fb0e2cf682fa2f4aadeca /core
parentb860b6769329137c24024c2330529d7b2078d89d (diff)
downloadgo-tangerine-86ba7432a965d9469ce1b4ccc2397ed2e08c9a3c.tar.gz
go-tangerine-86ba7432a965d9469ce1b4ccc2397ed2e08c9a3c.tar.zst
go-tangerine-86ba7432a965d9469ce1b4ccc2397ed2e08c9a3c.zip
txMeta storage as struct
Diffstat (limited to 'core')
-rw-r--r--core/block_processor.go28
1 files changed, 11 insertions, 17 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index ceb0ef8a7..c463bd083 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -235,7 +235,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
// This puts transactions in a extra db for rpc
for i, tx := range block.Transactions() {
- putTx(sm.extraDb, tx, block, i)
+ putTx(sm.extraDb, tx, block, uint64(i))
}
if uncle {
@@ -359,7 +359,7 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro
return state.Logs(), nil
}
-func putTx(db common.Database, tx *types.Transaction, block *types.Block, i int) {
+func putTx(db common.Database, tx *types.Transaction, block *types.Block, i uint64) {
rlpEnc, err := rlp.EncodeToBytes(tx)
if err != nil {
statelogger.Infoln("Failed encoding tx", err)
@@ -367,24 +367,18 @@ func putTx(db common.Database, tx *types.Transaction, block *types.Block, i int)
}
db.Put(tx.Hash().Bytes(), rlpEnc)
- rlpEnc, err = rlp.EncodeToBytes(block.Hash().Bytes())
- if err != nil {
- statelogger.Infoln("Failed encoding meta", err)
- return
+ var txExtra struct {
+ BlockHash common.Hash
+ BlockIndex uint64
+ Index uint64
}
- db.Put(append(tx.Hash().Bytes(), 0x0001), rlpEnc)
-
- rlpEnc, err = rlp.EncodeToBytes(block.Number().Bytes())
- if err != nil {
- statelogger.Infoln("Failed encoding meta", err)
- return
- }
- db.Put(append(tx.Hash().Bytes(), 0x0002), rlpEnc)
-
- rlpEnc, err = rlp.EncodeToBytes(i)
+ txExtra.BlockHash = block.Hash()
+ txExtra.BlockIndex = block.NumberU64()
+ txExtra.Index = i
+ rlpMeta, err := rlp.EncodeToBytes(txExtra)
if err != nil {
statelogger.Infoln("Failed encoding meta", err)
return
}
- db.Put(append(tx.Hash().Bytes(), 0x0003), rlpEnc)
+ db.Put(append(tx.Hash().Bytes(), 0x0001), rlpMeta)
}