Storing tx receipts in extraDb

This commit is contained in:
zsfelfoldi
2015-05-20 06:41:50 +02:00
parent 79042223dc
commit 00ec4132f8
2 changed files with 34 additions and 0 deletions

View File

@ -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)