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.
This commit is contained in:
parent
ab5aa4dd6d
commit
43873ec320
@ -253,28 +253,28 @@ func blockConnected() {
|
|||||||
// successful wallet will have the most up-to-date ticket status, the others
|
// successful wallet will have the most up-to-date ticket status, the others
|
||||||
// will be outdated.
|
// will be outdated.
|
||||||
for _, walletClient := range walletClients {
|
for _, walletClient := range walletClients {
|
||||||
dbTickets, err := db.GetVotableTickets()
|
votableTickets, err := db.GetVotableTickets()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s: db.GetVotableTickets failed: %v", funcName, err)
|
log.Errorf("%s: db.GetVotableTickets failed: %v", funcName, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the database has no votable tickets, there is nothing more to do
|
// If the database has no votable tickets, there is nothing more to do
|
||||||
if len(dbTickets) == 0 {
|
if len(votableTickets) == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the oldest block height from confirmed tickets.
|
// Find the oldest block height from confirmed tickets.
|
||||||
oldestHeight := findOldestHeight(dbTickets)
|
oldestHeight := findOldestHeight(votableTickets)
|
||||||
|
|
||||||
ticketInfo, err := walletClient.TicketInfo(oldestHeight)
|
ticketInfo, err := walletClient.TicketInfo(oldestHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s: dcrwallet.TicketInfo failed (wallet=%s): %v",
|
log.Errorf("%s: dcrwallet.TicketInfo failed (startHeight=%d, wallet=%s): %v",
|
||||||
funcName, walletClient.String(), err)
|
funcName, oldestHeight, walletClient.String(), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dbTicket := range dbTickets {
|
for _, dbTicket := range votableTickets {
|
||||||
tInfo, ok := ticketInfo[dbTicket.Hash]
|
tInfo, ok := ticketInfo[dbTicket.Hash]
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Warnf("%s: TicketInfo response did not include expected ticket (wallet=%s, ticketHash=%s)",
|
log.Warnf("%s: TicketInfo response did not include expected ticket (wallet=%s, ticketHash=%s)",
|
||||||
@ -283,7 +283,7 @@ func blockConnected() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch tInfo.Status {
|
switch tInfo.Status {
|
||||||
case "revoked":
|
case "missed", "expired", "revoked":
|
||||||
dbTicket.Outcome = database.Revoked
|
dbTicket.Outcome = database.Revoked
|
||||||
case "voted":
|
case "voted":
|
||||||
dbTicket.Outcome = database.Voted
|
dbTicket.Outcome = database.Voted
|
||||||
@ -448,8 +448,8 @@ func checkWalletConsistency() {
|
|||||||
// Get all tickets the wallet is aware of.
|
// Get all tickets the wallet is aware of.
|
||||||
walletTickets, err := walletClient.TicketInfo(oldestHeight)
|
walletTickets, err := walletClient.TicketInfo(oldestHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s: dcrwallet.TicketInfo failed (wallet=%s): %v",
|
log.Errorf("%s: dcrwallet.TicketInfo failed (startHeight=%d, wallet=%s): %v",
|
||||||
funcName, walletClient.String(), err)
|
funcName, oldestHeight, walletClient.String(), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,8 +506,8 @@ func checkWalletConsistency() {
|
|||||||
// Get all tickets the wallet is aware of.
|
// Get all tickets the wallet is aware of.
|
||||||
walletTickets, err := walletClient.TicketInfo(oldestHeight)
|
walletTickets, err := walletClient.TicketInfo(oldestHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s: dcrwallet.TicketInfo failed (wallet=%s): %v",
|
log.Errorf("%s: dcrwallet.TicketInfo failed (startHeight=%d, wallet=%s): %v",
|
||||||
funcName, walletClient.String(), err)
|
funcName, oldestHeight, walletClient.String(), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user