Merge pull request #1604 from obscuren/db-merge
core, eth, trie, xeth: merged state, chain, extra databases in one
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user