-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reject unvotable tickets. #93
Conversation
/payfee and /getaddress will now only accept tickets which are immature or live.
|
||
// CanTicketVote checks determines whether a ticket is able to vote at some | ||
// point in the future by checking that it is currently either immature or live. | ||
func (c *DcrdRPC) CanTicketVote(ticketHash string, netParams *chaincfg.Params) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davecgh could you give this function a once-over please?
rpc/dcrd.go
Outdated
return false, err | ||
} | ||
|
||
// Tickets which older than (TicketMaturity+TicketExpiry) are too old to vote. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing are
.
rpc/dcrd.go
Outdated
} | ||
|
||
// Tickets which older than (TicketMaturity+TicketExpiry) are too old to vote. | ||
if rawTx.Confirmations > int64(uint32(netParams.TicketMaturity)+netParams.TicketExpiry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks off by one to me. Tickets don't become live until the block after they reach ticket maturity.
This can be seen by noticing that the first tickets were mined in block 257 and didn't become live until 257+256+1 = 514 by looking at the fact the pool size became nonzero at that point.
Then, those tickets would have expired 40960 blocks after the point they became live. Ergo, a ticket mined in block 257 that didn't get selected would expire in block 514+ 40960 = 41474, and as luck would have it for this example, one of those tickets actually did end up expiring and was revoked in the aforementioned block.
So, running the numbers with what it would look like at block 41473 (one block before expiration) would give:
Confirmations = 41473 - 257 (block it was mined in) + 1 (including the block it was mined in) = 41217.
TicketMaturity + TicketExpiry = 40960 + 256 = 41216
Then if 41217 > 41216
is true, which is incorrect, because it wouldn't expire until the next block.
Thanks for explaining that Dave, I've added a |
/payfee and /getaddress will now only accept tickets which are immature or live.
Closes #56