aboutsummaryrefslogtreecommitdiffstats
path: root/core/block_processor.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-08-09 20:16:37 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-08-09 20:16:37 +0800
commit2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a (patch)
treee3e7d013e2ccae939df7dd1d8aa7dcb3802fadd7 /core/block_processor.go
parent07cb8092e7a41e80224dc63691146e8714f94ebf (diff)
parenta23478c0be94e1e727a64d20341b8d6f98d7f0a0 (diff)
downloadgo-tangerine-2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a.tar
go-tangerine-2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a.tar.gz
go-tangerine-2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a.tar.bz2
go-tangerine-2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a.tar.lz
go-tangerine-2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a.tar.xz
go-tangerine-2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a.tar.zst
go-tangerine-2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a.zip
Merge pull request #1604 from obscuren/db-merge
core, eth, trie, xeth: merged state, chain, extra databases in one
Diffstat (limited to 'core/block_processor.go')
-rw-r--r--core/block_processor.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index 6ed1bc8ef..477215356 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -41,8 +41,7 @@ const (
)
type BlockProcessor struct {
- db common.Database
- extraDb common.Database
+ chainDb common.Database
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex sync.Mutex
// Canonical block chain
@@ -57,10 +56,9 @@ type BlockProcessor struct {
eventMux *event.TypeMux
}
-func NewBlockProcessor(db, extra common.Database, pow pow.PoW, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
+func NewBlockProcessor(db common.Database, pow pow.PoW, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
sm := &BlockProcessor{
- db: db,
- extraDb: extra,
+ chainDb: db,
mem: make(map[string]*big.Int),
Pow: pow,
bc: chainManager,
@@ -199,7 +197,7 @@ func (sm *BlockProcessor) Process(block *types.Block) (logs state.Logs, receipts
func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs state.Logs, receipts types.Receipts, err error) {
// Create a new state based on the parent's root (e.g., create copy)
- state := state.New(parent.Root(), sm.db)
+ state := state.New(parent.Root(), sm.chainDb)
header := block.Header()
uncles := block.Uncles()
txs := block.Transactions()
@@ -340,7 +338,7 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
// GetBlockReceipts returns the receipts beloniging to the block hash
func (sm *BlockProcessor) GetBlockReceipts(bhash common.Hash) types.Receipts {
if block := sm.ChainManager().GetBlock(bhash); block != nil {
- return GetBlockReceipts(sm.extraDb, block.Hash())
+ return GetBlockReceipts(sm.chainDb, block.Hash())
}
return nil
@@ -350,7 +348,7 @@ func (sm *BlockProcessor) GetBlockReceipts(bhash common.Hash) types.Receipts {
// where it tries to get it from the (updated) method which gets them from the receipts or
// the depricated way by re-processing the block.
func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err error) {
- receipts := GetBlockReceipts(sm.extraDb, block.Hash())
+ receipts := GetBlockReceipts(sm.chainDb, block.Hash())
if len(receipts) > 0 {
// coalesce logs
for _, receipt := range receipts {
@@ -362,7 +360,7 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro
// TODO: remove backward compatibility
var (
parent = sm.bc.GetBlock(block.ParentHash())
- state = state.New(parent.Root(), sm.db)
+ state = state.New(parent.Root(), sm.chainDb)
)
sm.TransitionState(state, parent, block, true)