From 43873ec3209582ea21696821e2ca6be4c3da5006 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Wed, 27 Oct 2021 14:30:41 +0100 Subject: [PATCH] Record expired/missed tickets as revoked. This is an unfortunate workaround which is necessary because an instance of dcrwallet will only recognise a ticket as revoked if it has done the revoke itself. If another wallet broadcasts the revoke then the ticket will forever be reported as missed/expired. This causes problems for vspd when a wallet outside of the vspd deployment revokes a ticket (eg. a users ticketbuyer wallet). I'm happy to include this slightly dirty workaround because this should no longer be an issue when the auto-revoke work in DCP-0009 lands. --- background/background.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/background/background.go b/background/background.go index d826a94..b3ee198 100644 --- a/background/background.go +++ b/background/background.go @@ -253,28 +253,28 @@ func blockConnected() { // successful wallet will have the most up-to-date ticket status, the others // will be outdated. for _, walletClient := range walletClients { - dbTickets, err := db.GetVotableTickets() + votableTickets, err := db.GetVotableTickets() if err != nil { log.Errorf("%s: db.GetVotableTickets failed: %v", funcName, err) continue } // If the database has no votable tickets, there is nothing more to do - if len(dbTickets) == 0 { + if len(votableTickets) == 0 { break } // Find the oldest block height from confirmed tickets. - oldestHeight := findOldestHeight(dbTickets) + oldestHeight := findOldestHeight(votableTickets) ticketInfo, err := walletClient.TicketInfo(oldestHeight) if err != nil { - log.Errorf("%s: dcrwallet.TicketInfo failed (wallet=%s): %v", - funcName, walletClient.String(), err) + log.Errorf("%s: dcrwallet.TicketInfo failed (startHeight=%d, wallet=%s): %v", + funcName, oldestHeight, walletClient.String(), err) continue } - for _, dbTicket := range dbTickets { + for _, dbTicket := range votableTickets { tInfo, ok := ticketInfo[dbTicket.Hash] if !ok { log.Warnf("%s: TicketInfo response did not include expected ticket (wallet=%s, ticketHash=%s)", @@ -283,7 +283,7 @@ func blockConnected() { } switch tInfo.Status { - case "revoked": + case "missed", "expired", "revoked": dbTicket.Outcome = database.Revoked case "voted": dbTicket.Outcome = database.Voted @@ -448,8 +448,8 @@ func checkWalletConsistency() { // Get all tickets the wallet is aware of. walletTickets, err := walletClient.TicketInfo(oldestHeight) if err != nil { - log.Errorf("%s: dcrwallet.TicketInfo failed (wallet=%s): %v", - funcName, walletClient.String(), err) + log.Errorf("%s: dcrwallet.TicketInfo failed (startHeight=%d, wallet=%s): %v", + funcName, oldestHeight, walletClient.String(), err) continue } @@ -506,8 +506,8 @@ func checkWalletConsistency() { // Get all tickets the wallet is aware of. walletTickets, err := walletClient.TicketInfo(oldestHeight) if err != nil { - log.Errorf("%s: dcrwallet.TicketInfo failed (wallet=%s): %v", - funcName, walletClient.String(), err) + log.Errorf("%s: dcrwallet.TicketInfo failed (startHeight=%d, wallet=%s): %v", + funcName, oldestHeight, walletClient.String(), err) continue }