From 69b27ff1e6fb13febf2f85f5e0e5d5ba21325e82 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Tue, 19 Sep 2023 12:20:12 +0100 Subject: [PATCH] vspd: Rename blockConnected to update. The name blockConnected is not very accurate as this function is also called when vspd is initializing. It doesnt depend on a block having been connected at all, it can be called at any time. --- internal/vspd/vspd.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/vspd/vspd.go b/internal/vspd/vspd.go index f833ec8..cb1570d 100644 --- a/internal/vspd/vspd.go +++ b/internal/vspd/vspd.go @@ -80,9 +80,9 @@ func (v *Vspd) Run(ctx context.Context) { return } - // Run the block connected handler now to catch up with any blocks mined - // while vspd was shut down. - v.blockConnected(ctx) + // Run the update function now to catch up with any blocks mined while vspd + // was shut down. + v.update(ctx) // Stop if shutdown requested. if ctx.Err() != nil { @@ -117,10 +117,11 @@ func (v *Vspd) Run(ctx context.Context) { v.log.Errorf("dcrd connect error: %v", err) } - // Handle blockconnected notifications from dcrd. + // Run the update function every time a block connected notification is + // received from dcrd. case header := <-v.blockNotifChan: v.log.Debugf("Block notification %d (%s)", header.Height, header.BlockHash().String()) - v.blockConnected(ctx) + v.update(ctx) // Handle shutdown request. case <-ctx.Done(): @@ -246,10 +247,10 @@ func (v *Vspd) checkRevoked(ctx context.Context) error { return nil } -// blockConnected is called once when vspd starts up, and once each time a +// update is called once when vspd starts up, and once each time a // blockconnected notification is received from dcrd. -func (v *Vspd) blockConnected(ctx context.Context) { - const funcName = "blockConnected" +func (v *Vspd) update(ctx context.Context) { + const funcName = "update" dcrdClient, _, err := v.dcrd.Client() if err != nil {