mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
Updated lightchain data
This commit is contained in:
parent
29cb1de084
commit
e2beaa0fba
3 changed files with 10 additions and 15 deletions
|
|
@ -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
|
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 TestOdrGetBlockLes1(t *testing.T) { testOdr(t, 1, 1, odrGetBlock) }
|
||||||
|
//
|
||||||
//func TestOdrGetBlockLes2(t *testing.T) { testOdr(t, 2, 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
|
var block *types.Block
|
||||||
if bc != nil {
|
if bc != nil {
|
||||||
block = bc.GetBlockByHash(bhash)
|
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 TestOdrGetReceiptsLes1(t *testing.T) { testOdr(t, 1, 1, odrGetReceipts) }
|
||||||
|
//
|
||||||
//func TestOdrGetReceiptsLes2(t *testing.T) { testOdr(t, 2, 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
|
var receipts types.Receipts
|
||||||
if bc != nil {
|
if bc != nil {
|
||||||
receipts = core.GetBlockReceipts(db, bhash, core.GetBlockNumber(db, bhash))
|
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 TestOdrAccountsLes1(t *testing.T) { testOdr(t, 1, 1, odrAccounts) }
|
||||||
|
//
|
||||||
//func TestOdrAccountsLes2(t *testing.T) { testOdr(t, 2, 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")
|
dummyAddr := common.HexToAddress("1234567812345678123456781234567812345678")
|
||||||
acc := []common.Address{testBankAddress, acc1Addr, acc2Addr, dummyAddr}
|
acc := []common.Address{testBankAddress, acc1Addr, acc2Addr, dummyAddr}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -344,12 +344,8 @@ func (self *LightChain) postChainEvents(events []interface{}) {
|
||||||
// chain events when necessary.
|
// chain events when necessary.
|
||||||
func (self *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
|
func (self *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
state, err := self.State()
|
if i, err := self.hc.ValidateHeaderChain(chain, checkFreq); err != nil {
|
||||||
if err != nil {
|
return i, err
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
if i, err := self.hc.ValidateHeaderChain(chain, state, checkFreq); err != nil {
|
|
||||||
return i, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure only one thread manipulates the chain at once
|
// Make sure only one thread manipulates the chain at once
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
func testHeaderChainImport(chain []*types.Header, lightchain *LightChain) error {
|
||||||
for _, header := range chain {
|
for _, header := range chain {
|
||||||
// Try and validate the header
|
// Try and validate the header
|
||||||
state, _ := lightchain.State()
|
if err := lightchain.engine.VerifyHeader(lightchain.hc, header, true); err != nil {
|
||||||
if err := lightchain.engine.VerifyHeader(lightchain.hc, state, header, true); err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
// Manually insert the header into the database, but don't reorganize (allows subsequent testing)
|
// Manually insert the header into the database, but don't reorganize (allows subsequent testing)
|
||||||
lightchain.mu.Lock()
|
lightchain.mu.Lock()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue