Only log rollbacks for detached txstore blocks.
Instead of logging whenever there is a chain fork + reorg, only log if a detached block affects the wallet in some manner.
This commit is contained in:
parent
d75a3fc4e7
commit
938dfa1517
2 changed files with 9 additions and 2 deletions
|
@ -619,8 +619,6 @@ func (am *AccountManager) RegisterNewAccount(a *Account) error {
|
|||
// Rollback rolls back each managed Account to the state before the block
|
||||
// specified by height and hash was connected to the main chain.
|
||||
func (am *AccountManager) Rollback(height int32, hash *btcwire.ShaHash) error {
|
||||
log.Infof("Rolling back tx history since block height %v", height)
|
||||
|
||||
for _, a := range am.AllAccounts() {
|
||||
if err := a.TxStore.Rollback(height); err != nil {
|
||||
return err
|
||||
|
|
|
@ -808,6 +808,15 @@ func (s *Store) Rollback(height int32) error {
|
|||
detached := s.blocks[i:]
|
||||
s.blocks = s.blocks[:i]
|
||||
for _, b := range detached {
|
||||
movedTxs := len(b.txs)
|
||||
// Don't include coinbase transaction with number of moved txs.
|
||||
// There should always be at least one tx in a block collection,
|
||||
// and if there is a coinbase, it would be at index 0.
|
||||
if b.txs[0].tx.Index() == 0 {
|
||||
movedTxs--
|
||||
}
|
||||
log.Infof("Rolling back block %d (%d transactions marked "+
|
||||
"unconfirmed)", b.Height, movedTxs)
|
||||
delete(s.blockIndexes, b.Block.Height)
|
||||
for _, r := range b.txs {
|
||||
oldTxIndex := r.Tx().Index()
|
||||
|
|
Loading…
Add table
Reference in a new issue