Skip to content

Commit

Permalink
feat: update FollowTip to handle wrong provided tip
Browse files Browse the repository at this point in the history
Signed-off-by: Ales Verbic <[email protected]>
  • Loading branch information
verbotenj committed Jul 19, 2024
1 parent 675889c commit 4fa2e8f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions internal/utxorpc/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,24 @@ func (s *chainSyncServiceServer) FollowTip(
point = tip.Point
}

// Start the sync with the node
// Start the sync with the node with the provided point
err = oConn.ChainSync().Client.Sync([]ocommon.Point{point})
if err != nil {
log.Printf("ERROR: %s", err)
return err
log.Printf("ERROR syncing with provided point: %s", err)
// Get the current tip
tip, err := oConn.ChainSync().Client.GetCurrentTip()
if err != nil {
log.Printf("ERROR: getting current tip: %s", err)
return err
}
point = tip.Point

// Attempt to sync with the current tip
err = oConn.ChainSync().Client.Sync([]ocommon.Point{point})
if err != nil {
log.Printf("ERROR: syncing with current tip: %s", err)
return err
}
}

// Wait for events
Expand Down

0 comments on commit 4fa2e8f

Please sign in to comment.