diff options
author | zsfelfoldi <zsfelfoldi@gmail.com> | 2015-05-20 12:41:50 +0800 |
---|---|---|
committer | zsfelfoldi <zsfelfoldi@gmail.com> | 2015-05-20 12:41:50 +0800 |
commit | 00ec4132f89527a6e2ae6b1d3842c447cab38cef (patch) | |
tree | f082256647e69810c9a2b5a1cfef52f0ce851600 /core | |
parent | 79042223dc5f2ae5d4a2ed73d18907440a963093 (diff) | |
download | go-tangerine-00ec4132f89527a6e2ae6b1d3842c447cab38cef.tar go-tangerine-00ec4132f89527a6e2ae6b1d3842c447cab38cef.tar.gz go-tangerine-00ec4132f89527a6e2ae6b1d3842c447cab38cef.tar.bz2 go-tangerine-00ec4132f89527a6e2ae6b1d3842c447cab38cef.tar.lz go-tangerine-00ec4132f89527a6e2ae6b1d3842c447cab38cef.tar.xz go-tangerine-00ec4132f89527a6e2ae6b1d3842c447cab38cef.tar.zst go-tangerine-00ec4132f89527a6e2ae6b1d3842c447cab38cef.zip |
Storing tx receipts in extraDb
Diffstat (limited to 'core')
-rw-r--r-- | core/block_processor.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index 20e6722a4..3a224059b 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -23,6 +23,8 @@ const ( BlockChainVersion = 2 ) +var receiptsPre = []byte("receipts-") + type BlockProcessor struct { db common.Database extraDb common.Database @@ -262,9 +264,23 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st putTx(sm.extraDb, tx, block, uint64(i)) } + receiptsRlp := block.Receipts().RlpEncode() + sm.extraDb.Put(append(receiptsPre, block.Hash().Bytes()...), receiptsRlp) + return state.Logs(), nil } +func (self *BlockProcessor) GetBlockReceipts(bhash common.Hash) (receipts types.Receipts, err error) { + var rdata []byte + rdata, err = self.extraDb.Get(append(receiptsPre, bhash[:]...)) + + if err == nil { + err = rlp.DecodeBytes(rdata, &receipts) + } + return + +} + // Validates the current block. Returns an error if the block was invalid, // an uncle or anything that isn't on the current block chain. // Validation validates easy over difficult (dagger takes longer time = difficult) |