Skip to content

Commit

Permalink
Rollback transactions past the last saved recent block.
Browse files Browse the repository at this point in the history
If a long reorganize occurs farther back than the last saved recent
block hash (currently max 20 are saved) a full rescan is triggered
since there is no guarantee the previous blocks weren't also removed
in the reorg.  In this case, the address manager was set unsynced, but
transaction history was not rolled back as well.  This commit corrects
this by unconfirming all transactions but those in the genesis block.
  • Loading branch information
jrick committed May 14, 2015
1 parent 47ca1ca commit edde89c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions wallet/chainntfns.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ func (w *Wallet) disconnectBlock(bs waddrmgr.BlockStamp) error {
// earliest blockstamp the addresses in the manager are
// known to have been created.
w.Manager.SetSyncedTo(nil)
// Rollback everything but the genesis block.
err := w.TxStore.Rollback(1)
if err != nil {
return err
}
}
}
w.notifyDisconnectedBlock(bs)
Expand Down

0 comments on commit edde89c

Please sign in to comment.