make_history_check_optional (#1467)

This commit is contained in:
Alex Sharov 2021-02-05 16:46:43 +07:00 committed by GitHub
parent f351eea439
commit bf04a6e73d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,7 +195,7 @@ func syncBySmallSteps(db ethdb.Database, ctx context.Context) error {
if err := st.Run(db, tx); err != nil {
return err
}
if err := checkChanges(expectedAccountChanges, tx, expectedStorageChanges, execAtBlock); err != nil {
if err := checkChanges(expectedAccountChanges, tx, expectedStorageChanges, execAtBlock, sm.History); err != nil {
return err
}
@ -226,7 +226,7 @@ func syncBySmallSteps(db ethdb.Database, ctx context.Context) error {
return nil
}
func checkChanges(expectedAccountChanges map[uint64]*changeset.ChangeSet, db ethdb.Database, expectedStorageChanges map[uint64]*changeset.ChangeSet, execAtBlock uint64) error {
func checkChanges(expectedAccountChanges map[uint64]*changeset.ChangeSet, db ethdb.Database, expectedStorageChanges map[uint64]*changeset.ChangeSet, execAtBlock uint64, historyEnabled bool) error {
for blockN := range expectedAccountChanges {
if err := checkChangeSet(db, blockN, expectedAccountChanges[blockN], expectedStorageChanges[blockN]); err != nil {
return err
@ -235,11 +235,13 @@ func checkChanges(expectedAccountChanges map[uint64]*changeset.ChangeSet, db eth
delete(expectedStorageChanges, blockN)
}
if err := checkHistory(db, dbutils.PlainAccountChangeSetBucket, execAtBlock); err != nil {
return err
}
if err := checkHistory(db, dbutils.PlainStorageChangeSetBucket, execAtBlock); err != nil {
return err
if historyEnabled {
if err := checkHistory(db, dbutils.PlainAccountChangeSetBucket, execAtBlock); err != nil {
return err
}
if err := checkHistory(db, dbutils.PlainStorageChangeSetBucket, execAtBlock); err != nil {
return err
}
}
return nil
}