Skip to content

Commit

Permalink
Record expired/missed tickets as revoked.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jholdstock committed Nov 16, 2021
1 parent ab5aa4d commit 43873ec
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions background/background.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 43873ec

Please sign in to comment.