From e2beaa0fbae1308ec6260f7d14808f3bd28018fd Mon Sep 17 00:00:00 2001 From: AnilChinchawale Date: Tue, 29 Jan 2019 04:50:22 +0530 Subject: [PATCH] Updated lightchain data --- les/odr_test.go | 12 ++++++------ light/lightchain.go | 8 ++------ light/lightchain_test.go | 5 ++--- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/les/odr_test.go b/les/odr_test.go index 1e3dacaa65..a8bc365e89 100644 --- a/les/odr_test.go +++ b/les/odr_test.go @@ -39,10 +39,10 @@ import ( type odrTestFn func(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte //func TestOdrGetBlockLes1(t *testing.T) { testOdr(t, 1, 1, odrGetBlock) } - +// //func TestOdrGetBlockLes2(t *testing.T) { testOdr(t, 2, 1, odrGetBlock) } -//func odrGetBlock(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { +func odrGetBlock(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { var block *types.Block if bc != nil { block = bc.GetBlockByHash(bhash) @@ -57,10 +57,10 @@ type odrTestFn func(ctx context.Context, db ethdb.Database, config *params.Chain } //func TestOdrGetReceiptsLes1(t *testing.T) { testOdr(t, 1, 1, odrGetReceipts) } - +// //func TestOdrGetReceiptsLes2(t *testing.T) { testOdr(t, 2, 1, odrGetReceipts) } -//func odrGetReceipts(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { +func odrGetReceipts(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { var receipts types.Receipts if bc != nil { receipts = core.GetBlockReceipts(db, bhash, core.GetBlockNumber(db, bhash)) @@ -75,10 +75,10 @@ type odrTestFn func(ctx context.Context, db ethdb.Database, config *params.Chain } //func TestOdrAccountsLes1(t *testing.T) { testOdr(t, 1, 1, odrAccounts) } - +// //func TestOdrAccountsLes2(t *testing.T) { testOdr(t, 2, 1, odrAccounts) } -//func odrAccounts(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { +func odrAccounts(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte { dummyAddr := common.HexToAddress("1234567812345678123456781234567812345678") acc := []common.Address{testBankAddress, acc1Addr, acc2Addr, dummyAddr} diff --git a/light/lightchain.go b/light/lightchain.go index b778f70eb7..2784615d35 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -344,12 +344,8 @@ func (self *LightChain) postChainEvents(events []interface{}) { // chain events when necessary. func (self *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) { start := time.Now() - state, err := self.State() - if err != nil { - return 0, err - } - if i, err := self.hc.ValidateHeaderChain(chain, state, checkFreq); err != nil { - return i, err + if i, err := self.hc.ValidateHeaderChain(chain, checkFreq); err != nil { + return i, err } // Make sure only one thread manipulates the chain at once diff --git a/light/lightchain_test.go b/light/lightchain_test.go index 175b0d83c2..0af7551d41 100644 --- a/light/lightchain_test.go +++ b/light/lightchain_test.go @@ -117,9 +117,8 @@ func testFork(t *testing.T, LightChain *LightChain, i, n int, comparator func(td func testHeaderChainImport(chain []*types.Header, lightchain *LightChain) error { for _, header := range chain { // Try and validate the header - state, _ := lightchain.State() - if err := lightchain.engine.VerifyHeader(lightchain.hc, state, header, true); err != nil { - return err + if err := lightchain.engine.VerifyHeader(lightchain.hc, header, true); err != nil { + return err } // Manually insert the header into the database, but don't reorganize (allows subsequent testing) lightchain.mu.Lock()