From 32ee3fb74d938e603e0aa2bc68cb4bfb571d83bf Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Fri, 22 Jul 2022 13:19:11 -0300 Subject: [PATCH] rpcserver: Avoid error in handleRebroadcastWinners. This downgrades an error when rebroadcasting the winning tickets to a logged warning. This is necessary because it is a legitimate state to have a chain tip header returned by the Chain.TipGeneration() while the actual block data is not yet available for the LotteryDataForBlock to complete. Prior to this change, a voting wallet connecting to a dcrd instance with multiple chain tip headers without the associated data would be unable to re-start voting for blocks due to the associated RPC call failing. --- internal/rpcserver/rpcwebsocket.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/rpcserver/rpcwebsocket.go b/internal/rpcserver/rpcwebsocket.go index 350eec8f..79fc6b9b 100644 --- a/internal/rpcserver/rpcwebsocket.go +++ b/internal/rpcserver/rpcwebsocket.go @@ -2071,8 +2071,11 @@ func handleRebroadcastWinners(wsc *wsClient, icmd interface{}) (interface{}, err for i := range blocks { winningTickets, _, _, err := cfg.Chain.LotteryDataForBlock(&blocks[i]) if err != nil { - return nil, rpcInternalError("Lottery data for block "+ - "failed: "+err.Error(), "") + // This can legitimately happen if we have the block + // header but not the block data, so just log a warning + // and keep sending notifications. + log.Warnf("Lottery data for block failed: %v", err) + continue } ntfnData := &WinningTicketsNtfnData{ BlockHash: blocks[i],