code: func (self *StateDB) RevertToSnapshot(revid int) {
  	// Find the snapshot in the stack of valid snapshots.
  	idx := sort.Search(len(self.validRevisions), func(i int) bool {
  		return self.validRevisions[i].id >= revid
  	})
  	if idx == len(self.validRevisions) || self.validRevisions[idx].id != revid {
  		panic(fmt.Errorf("revision id %v cannot be reverted", revid))
  	}
  	snapshot := self.validRevisions[idx].journalIndex
  
  	// Replay the journal to undo changes and remove invalidated snapshots
  	self.journal.revert(self, snapshot)
  	self.validRevisions = self.validRevisions[:idx]
  }
docs: // RevertToSnapshot reverts all state changes made since the given revision.