diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-01 18:49:10 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-01 18:49:10 +0800 |
commit | 6afc5e762af0f81b70256ebb7e830b09caf17be0 (patch) | |
tree | fa6c2a4cff1c3799c623e4b361ac3052baa0441e /core/block_processor.go | |
parent | 4e8f8cfab701bb6c4ad2b8cf166d642f408ca398 (diff) | |
parent | 02fb83782eab5d6ad394aca58daab77a9525d5ff (diff) | |
download | dexon-6afc5e762af0f81b70256ebb7e830b09caf17be0.tar.gz dexon-6afc5e762af0f81b70256ebb7e830b09caf17be0.tar.zst dexon-6afc5e762af0f81b70256ebb7e830b09caf17be0.zip |
Merge branch 'hexify' of https://github.com/tgerring/go-ethereum into tgerring-hexify
Diffstat (limited to 'core/block_processor.go')
-rw-r--r-- | core/block_processor.go | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index 8fbf760af..f7f0cd188 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -233,8 +233,9 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big sm.txpool.RemoveSet(block.Transactions()) } - for _, tx := range block.Transactions() { - putTx(sm.extraDb, tx) + // This puts transactions in a extra db for rpc + for i, tx := range block.Transactions() { + putTx(sm.extraDb, tx, block, uint64(i)) } if uncle { @@ -362,11 +363,26 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro return state.Logs(), nil } -func putTx(db common.Database, tx *types.Transaction) { +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) return } db.Put(tx.Hash().Bytes(), rlpEnc) + + var txExtra struct { + BlockHash common.Hash + BlockIndex uint64 + Index uint64 + } + 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(), 0x0001), rlpMeta) } |