diff options
Diffstat (limited to 'light')
-rw-r--r-- | light/lightchain.go | 28 | ||||
-rw-r--r-- | light/lightchain_test.go | 14 | ||||
-rw-r--r-- | light/odr_test.go | 3 | ||||
-rw-r--r-- | light/txpool_test.go | 3 |
4 files changed, 13 insertions, 35 deletions
diff --git a/light/lightchain.go b/light/lightchain.go index 773c0f38b..4370dc0fc 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -102,31 +102,10 @@ func NewLightChain(odr OdrBackend, config *params.ChainConfig, pow pow.PoW, mux log.Warn("Wrote default ethereum genesis block") } - if bc.genesisBlock.Hash() == (common.Hash{212, 229, 103, 64, 248, 118, 174, 248, 192, 16, 184, 106, 64, 213, 245, 103, 69, 161, 24, 208, 144, 106, 52, 230, 154, 236, 140, 13, 177, 203, 143, 163}) { + if bc.genesisBlock.Hash() == params.MainNetGenesisHash { // add trusted CHT - if config.DAOForkSupport { - WriteTrustedCht(bc.chainDb, TrustedCht{ - Number: 637, - Root: common.HexToHash("01e408d9b1942f05dba1a879f3eaafe34d219edaeb8223fecf1244cc023d3e23"), - }) - } else { - WriteTrustedCht(bc.chainDb, TrustedCht{ - Number: 523, - Root: common.HexToHash("c035076523faf514038f619715de404a65398c51899b5dccca9c05b00bc79315"), - }) - } + WriteTrustedCht(bc.chainDb, TrustedCht{Number: 805, Root: common.HexToHash("85e4286fe0a730390245c49de8476977afdae0eb5530b277f62a52b12313d50f")}) log.Info("Added trusted CHT for mainnet") - } else { - if bc.genesisBlock.Hash() == (common.Hash{12, 215, 134, 162, 66, 93, 22, 241, 82, 198, 88, 49, 108, 66, 62, 108, 225, 24, 30, 21, 195, 41, 88, 38, 215, 201, 144, 76, 186, 156, 227, 3}) { - // add trusted CHT for testnet - WriteTrustedCht(bc.chainDb, TrustedCht{ - Number: 452, - Root: common.HexToHash("511da2c88e32b14cf4a4e62f7fcbb297139faebc260a4ab5eb43cce6edcba324"), - }) - log.Info("Added trusted CHT for testnet") - } else { - DeleteTrustedCht(bc.chainDb) - } } if err := bc.loadLastState(); err != nil { @@ -169,6 +148,9 @@ func (self *LightChain) loadLastState() error { headerTd := self.GetTd(header.Hash(), header.Number.Uint64()) log.Info("Loaded most recent local header", "number", header.Number, "hash", header.Hash(), "td", headerTd) + // Try to be smart and issue a pow verification for the head to pre-generate caches + go self.pow.Verify(types.NewBlockWithHeader(header)) + return nil } diff --git a/light/lightchain_test.go b/light/lightchain_test.go index 0ba925887..8a99c69f1 100644 --- a/light/lightchain_test.go +++ b/light/lightchain_test.go @@ -22,7 +22,6 @@ import ( "runtime" "testing" - "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" @@ -67,7 +66,7 @@ func newCanonical(n int) (ethdb.Database, *LightChain, error) { // Initialize a fresh chain with only a genesis block genesis, _ := core.WriteTestNetGenesisBlock(db) - blockchain, _ := NewLightChain(&dummyOdr{db: db}, testChainConfig(), core.FakePow{}, evmux) + blockchain, _ := NewLightChain(&dummyOdr{db: db}, testChainConfig(), pow.FakePow{}, evmux) // Create and inject the requested chain if n == 0 { return db, blockchain, nil @@ -82,15 +81,10 @@ func init() { runtime.GOMAXPROCS(runtime.NumCPU()) } -func thePow() pow.PoW { - pow, _ := ethash.NewForTesting() - return pow -} - func theLightChain(db ethdb.Database, t *testing.T) *LightChain { var eventMux event.TypeMux core.WriteTestNetGenesisBlock(db) - LightChain, err := NewLightChain(&dummyOdr{db: db}, testChainConfig(), thePow(), &eventMux) + LightChain, err := NewLightChain(&dummyOdr{db: db}, testChainConfig(), pow.NewTestEthash(), &eventMux) if err != nil { t.Error("failed creating LightChain:", err) t.FailNow() @@ -311,7 +305,7 @@ func (odr *dummyOdr) Retrieve(ctx context.Context, req OdrRequest) error { func chm(genesis *types.Block, db ethdb.Database) *LightChain { odr := &dummyOdr{db: db} var eventMux event.TypeMux - bc := &LightChain{odr: odr, chainDb: db, genesisBlock: genesis, eventMux: &eventMux, pow: core.FakePow{}} + bc := &LightChain{odr: odr, chainDb: db, genesisBlock: genesis, eventMux: &eventMux, pow: pow.FakePow{}} bc.hc, _ = core.NewHeaderChain(db, testChainConfig(), bc.Validator, bc.getProcInterrupt) bc.bodyCache, _ = lru.New(100) bc.bodyRLPCache, _ = lru.New(100) @@ -394,7 +388,7 @@ func TestReorgBadHeaderHashes(t *testing.T) { core.BadHashes[headers[3].Hash()] = true defer func() { delete(core.BadHashes, headers[3].Hash()) }() // Create a new chain manager and check it rolled back the state - ncm, err := NewLightChain(&dummyOdr{db: db}, testChainConfig(), core.FakePow{}, new(event.TypeMux)) + ncm, err := NewLightChain(&dummyOdr{db: db}, testChainConfig(), pow.FakePow{}, new(event.TypeMux)) if err != nil { t.Fatalf("failed to create new chain manager: %v", err) } diff --git a/light/odr_test.go b/light/odr_test.go index 6987db644..e2eced346 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -33,6 +33,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/pow" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" "golang.org/x/net/context" @@ -247,7 +248,7 @@ func testChainGen(i int, block *core.BlockGen) { func testChainOdr(t *testing.T, protocol int, expFail uint64, fn odrTestFn) { var ( evmux = new(event.TypeMux) - pow = new(core.FakePow) + pow = new(pow.FakePow) sdb, _ = ethdb.NewMemDatabase() ldb, _ = ethdb.NewMemDatabase() genesis = core.WriteGenesisBlockForTesting(sdb, core.GenesisAccount{Address: testBankAddress, Balance: testBankFunds}) diff --git a/light/txpool_test.go b/light/txpool_test.go index af2dcbbef..980c7c898 100644 --- a/light/txpool_test.go +++ b/light/txpool_test.go @@ -29,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/pow" "golang.org/x/net/context" ) @@ -82,7 +83,7 @@ func TestTxPool(t *testing.T) { var ( evmux = new(event.TypeMux) - pow = new(core.FakePow) + pow = new(pow.FakePow) sdb, _ = ethdb.NewMemDatabase() ldb, _ = ethdb.NewMemDatabase() genesis = core.WriteGenesisBlockForTesting(sdb, core.GenesisAccount{Address: testBankAddress, Balance: testBankFunds}) |