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.
This commit is contained in:
jholdstock 2023-09-19 12:20:12 +01:00 committed by Jamie Holdstock
parent 841ac77890
commit 69b27ff1e6

View File

@ -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 {