Skip to content

Commit

Permalink
pool: fix confirmed work cache signalling.
Browse files Browse the repository at this point in the history
This fixes a bug where solo pool gui where not
updating mined work properly because the cache
was not being properly updated on block connections.
This fix also moe efficiently confirms work.
  • Loading branch information
dnldd committed Jan 5, 2021
1 parent bb597f2 commit 49287a9
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions pool/chainstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,25 @@ func (cs *ChainState) handleChainUpdates(ctx context.Context) {
continue
}

// Update accepted work as confirmed mined.
work.Confirmed = true
err = cs.cfg.db.updateAcceptedWork(work)
if err != nil {
// Errors generated updating work state indicate an underlying
// issue accessing the database. The chainstate process will
// be terminated as a result.
log.Errorf("unable to confirm accepted work for block "+
"%s: %v", header.PrevBlock.String(), err)
close(msg.Done)
cs.cfg.Cancel()
continue
}
log.Infof("Mined work %s confirmed by connected block #%d",
header.PrevBlock.String(), header.Height)

// Signal the gui cache of the confirmed mined work.
cs.cfg.SignalCache(Confirmed)

if !cs.cfg.SoloPool {
count, err := cs.cfg.db.pendingPaymentsForBlockHash(parentHash)
if err != nil {
Expand Down Expand Up @@ -369,30 +388,11 @@ func (cs *ChainState) handleChainUpdates(ctx context.Context) {
// Errors generated creating payments are fatal since it is
// required to distribute payments to participating miners.
// The chainstate process will be terminated as a result.
log.Errorf("unable to generate payments: %v", err)
log.Error(err)
close(msg.Done)
cs.cfg.Cancel()
continue
}

// Update accepted work as confirmed mined.
work.Confirmed = true
err = cs.cfg.db.updateAcceptedWork(work)
if err != nil {
// Errors generated updating work state indicate an underlying
// issue accessing the database. The chainstate process will
// be terminated as a result.
log.Errorf("unable to confirm accepted work for block "+
"%s: %v", header.PrevBlock.String(), err)
close(msg.Done)
cs.cfg.Cancel()
continue
}
log.Infof("Mined work %s confirmed by connected block #%d",
header.PrevBlock.String(), header.Height)

// Signal the gui cache of the confirmed mined work.
cs.cfg.SignalCache(Confirmed)
}

close(msg.Done)
Expand Down

0 comments on commit 49287a9

Please sign in to comment.