Left comments on all PluGeth code injections

This commit is contained in:
philip-morlier
2022-04-04 15:40:56 -05:00
committed by Austin Roberts
parent 4211c5c401
commit fd0aaa1d6b
8 changed files with 22 additions and 3 deletions
+6 -1
View File
@@ -151,6 +151,7 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
sdb.snapStorage = make(map[common.Hash]map[common.Hash][]byte)
}
}
// Start PluGeth section
if sdb.snap == nil {
log.Debug("Snapshots not availble. Using plugin snapshot.")
sdb.snap = &pluginSnapshot{root}
@@ -158,6 +159,7 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
sdb.snapAccounts = make(map[common.Hash][]byte)
sdb.snapStorage = make(map[common.Hash]map[common.Hash][]byte)
}
// End PluGeth section
return sdb, nil
}
@@ -891,6 +893,7 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
func (s *StateDB) Prepare(thash common.Hash, ti int) {
s.thash = thash
s.txIndex = ti
s.accessList = newAccessList()
}
func (s *StateDB) clearJournalAndRefund() {
@@ -976,8 +979,10 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
}
// Only update if there's a state transition (skip empty Clique blocks)
if parent := s.snap.Root(); parent != root {
//begin PluGeth code injection
pluginStateUpdate(root, parent, s.snapDestructs, s.snapAccounts, s.snapStorage, codeUpdates)
if _, ok := s.snap.(*pluginSnapshot); !ok && s.snaps != nil {
if _, ok := s.snap.(*pluginSnapshot); !ok && s.snaps != nil { // This if statement (but not its content) was added by PluGeth
//end PluGeth injection
if err := s.snaps.Update(root, parent, s.snapDestructs, s.snapAccounts, s.snapStorage); err != nil {
log.Warn("Failed to update snapshot tree", "from", parent, "to", root, "err", err)
}