Commit 8b58cd01 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke

Merge pull request #2081 from zsfelfoldi/light-chain

core: create a header chain structure shared by full and light clients
parents bff9ceb6 73d21ea6
This diff is collapsed.
...@@ -472,11 +472,16 @@ func makeBlockChainWithDiff(genesis *types.Block, d []int, seed byte) []*types.B ...@@ -472,11 +472,16 @@ func makeBlockChainWithDiff(genesis *types.Block, d []int, seed byte) []*types.B
func chm(genesis *types.Block, db ethdb.Database) *BlockChain { func chm(genesis *types.Block, db ethdb.Database) *BlockChain {
var eventMux event.TypeMux var eventMux event.TypeMux
bc := &BlockChain{chainDb: db, genesisBlock: genesis, eventMux: &eventMux, pow: FakePow{}, rand: rand.New(rand.NewSource(0))} bc := &BlockChain{
bc.headerCache, _ = lru.New(100) chainDb: db,
genesisBlock: genesis,
eventMux: &eventMux,
pow: FakePow{},
}
valFn := func() HeaderValidator { return bc.Validator() }
bc.hc, _ = NewHeaderChain(db, valFn, bc.getProcInterrupt)
bc.bodyCache, _ = lru.New(100) bc.bodyCache, _ = lru.New(100)
bc.bodyRLPCache, _ = lru.New(100) bc.bodyRLPCache, _ = lru.New(100)
bc.tdCache, _ = lru.New(100)
bc.blockCache, _ = lru.New(100) bc.blockCache, _ = lru.New(100)
bc.futureBlocks, _ = lru.New(100) bc.futureBlocks, _ = lru.New(100)
bc.SetValidator(bproc{}) bc.SetValidator(bproc{})
......
This diff is collapsed.
...@@ -38,14 +38,22 @@ import ( ...@@ -38,14 +38,22 @@ import (
// ValidateHeader validates the given header and parent and returns an error // ValidateHeader validates the given header and parent and returns an error
// if it failed to do so. // if it failed to do so.
// //
// ValidateStack validates the given statedb and optionally the receipts and // ValidateState validates the given statedb and optionally the receipts and
// gas used. The implementor should decide what to do with the given input. // gas used. The implementor should decide what to do with the given input.
type Validator interface { type Validator interface {
HeaderValidator
ValidateBlock(block *types.Block) error ValidateBlock(block *types.Block) error
ValidateHeader(header, parent *types.Header, checkPow bool) error
ValidateState(block, parent *types.Block, state *state.StateDB, receipts types.Receipts, usedGas *big.Int) error ValidateState(block, parent *types.Block, state *state.StateDB, receipts types.Receipts, usedGas *big.Int) error
} }
// HeaderValidator is an interface for validating headers only
//
// ValidateHeader validates the given header and parent and returns an error
// if it failed to do so.
type HeaderValidator interface {
ValidateHeader(header, parent *types.Header, checkPow bool) error
}
// Processor is an interface for processing blocks using a given initial state. // Processor is an interface for processing blocks using a given initial state.
// //
// Process takes the block to be processed and the statedb upon which the // Process takes the block to be processed and the statedb upon which the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment