waddrmgr/sync: expose verification status in Manager's birthday block methods

This commit is contained in:
Wilmer Paulino 2018-11-15 17:59:01 -08:00
parent 6568c433fe
commit 7c377b2906
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

View file

@ -112,15 +112,26 @@ func (m *Manager) SetBirthday(ns walletdb.ReadWriteBucket,
} }
// BirthdayBlock returns the birthday block, or earliest block a key could have // BirthdayBlock returns the birthday block, or earliest block a key could have
// been used, for the manager. // been used, for the manager. A boolean is also returned to indicate whether
func (m *Manager) BirthdayBlock(ns walletdb.ReadBucket) (BlockStamp, error) { // the birthday block has been verified as correct.
return fetchBirthdayBlock(ns) func (m *Manager) BirthdayBlock(ns walletdb.ReadBucket) (BlockStamp, bool, error) {
birthdayBlock, err := fetchBirthdayBlock(ns)
if err != nil {
return BlockStamp{}, false, err
}
return birthdayBlock, fetchBirthdayBlockVerification(ns), nil
} }
// SetBirthdayBlock sets the birthday block, or earliest time a key could have // SetBirthdayBlock sets the birthday block, or earliest time a key could have
// been used, for the manager. // been used, for the manager. The verified boolean can be used to specify
// whether this birthday block should be sanity checked to determine if there
// exists a better candidate to prevent less block fetching.
func (m *Manager) SetBirthdayBlock(ns walletdb.ReadWriteBucket, func (m *Manager) SetBirthdayBlock(ns walletdb.ReadWriteBucket,
block BlockStamp) error { block BlockStamp, verified bool) error {
return putBirthdayBlock(ns, block) if err := putBirthdayBlock(ns, block); err != nil {
return err
}
return putBirthdayBlockVerification(ns, verified)
} }