wallet/chainntfns: make birthdaySanityCheck return ErrBirthdayBlockNotSet
This commit is contained in:
parent
cc77e41198
commit
80450c9033
2 changed files with 6 additions and 11 deletions
|
@ -118,7 +118,7 @@ func (w *Wallet) handleChainNotifications() {
|
|||
birthdayBlock, err := birthdaySanityCheck(
|
||||
chainClient, birthdayStore,
|
||||
)
|
||||
if err != nil {
|
||||
if err != nil && !waddrmgr.IsError(err, waddrmgr.ErrBirthdayBlockNotSet) {
|
||||
err := fmt.Errorf("unable to sanity "+
|
||||
"check wallet birthday block: %v",
|
||||
err)
|
||||
|
@ -450,20 +450,15 @@ func (s *walletBirthdayStore) SetBirthdayBlock(block waddrmgr.BlockStamp) error
|
|||
// with the backend, but before it begins syncing. This is done as the second
|
||||
// part to the wallet's address manager migration where we populate the birthday
|
||||
// block to ensure we do not miss any relevant events throughout rescans.
|
||||
// waddrmgr.ErrBirthdayBlockNotSet is returned if the birthday block has not
|
||||
// been set yet.
|
||||
func birthdaySanityCheck(chainConn chainConn,
|
||||
birthdayStore birthdayStore) (*waddrmgr.BlockStamp, error) {
|
||||
|
||||
// We'll start by fetching our wallet's birthday timestamp and block.
|
||||
birthdayTimestamp := birthdayStore.Birthday()
|
||||
birthdayBlock, birthdayBlockVerified, err := birthdayStore.BirthdayBlock()
|
||||
switch {
|
||||
// If our wallet's birthday block has not been set yet, then this is our
|
||||
// initial sync, so we'll defer setting it until then.
|
||||
case waddrmgr.IsError(err, waddrmgr.ErrBirthdayBlockNotSet):
|
||||
return nil, nil
|
||||
|
||||
// Otherwise, we'll return the error if there was one.
|
||||
case err != nil:
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -147,8 +147,8 @@ func TestBirthdaySanityCheckEmptyBirthdayBlock(t *testing.T) {
|
|||
birthdayStore := &mockBirthdayStore{}
|
||||
|
||||
birthdayBlock, err := birthdaySanityCheck(chainConn, birthdayStore)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to sanity check birthday block: %v", err)
|
||||
if !waddrmgr.IsError(err, waddrmgr.ErrBirthdayBlockNotSet) {
|
||||
t.Fatalf("expected ErrBirthdayBlockNotSet, got %v", err)
|
||||
}
|
||||
|
||||
if birthdayBlock != nil {
|
||||
|
|
Loading…
Reference in a new issue