Skip to content
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

multi: improve handling of low fee tickets #219

Merged
merged 9 commits into from
Nov 24, 2017
Merged

multi: improve handling of low fee tickets #219

merged 9 commits into from
Nov 24, 2017

Conversation

jolan
Copy link
Contributor

@jolan jolan commented Oct 16, 2017

This brings proper support for handling invalid/low fee tickets into the stakepool.

Basically it adds storage to the DB for saving added tickets, an admin UI to remove/add to the table, and then pushes/pulls the lists to/from stakepoold.

Not really sure about the gRPC server <-> main app ctx channel stuff. Seems to work OK but maybe there's a better way to do it.

Closes #134.
Closes #209.
Closes #218.

Also makes the fee checking fast per discussions with @chappjc and @jrick.

This also paves the way for closing some of the other open issues like #180 & #201.

Works for me™ so far but needs more testing and review.

@jolan jolan changed the title add table for storing low fee tickets multi: improve handling of low fee tickets Oct 16, 2017
@jrick
Copy link
Member

jrick commented Oct 16, 2017

Is this the last of the bits needed to remove the remaining stake pool code out of dcrwallet?

}

// MsgTxFromHex returns a wire.MsgTx struct built from the transaction hex string
func MsgTxFromHex(txhex string) *wire.MsgTx {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to return or log the error too.

@jolan
Copy link
Contributor Author

jolan commented Oct 16, 2017

@jrick This lays the foundation for getting there. I think what's left on the stake pool side is:

  • Improve the gRPC client code that dcrstakepool is using (there's a TODO there; still thinking what that should look like) so it is ready to be user facing.
  • Switch user facing tickets page from stakepooluserinfo to using data from stakepoold gRPC. This would provide "Live" and "Invalid" but not Missed/Voted/Expired.

)

// Public API version constants
const (
semverString = "3.0.0"
semverMajor = 3
grpcTimeout = time.Millisecond * 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that silly short?

Copy link
Contributor Author

@jolan jolan Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's just copying or overwriting a map which is ~2ms on my machine. I think it could be re-written to not need a timeout.


for {
select {
case addedLowFeeTickets := <-s.grpcGetAddedLowFeeTicketsResultsChan:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the request should be creating this channel instead of reusing a channel in the service implementation. As it is, I don't believe this will work when multiple clients are hitting the same requests at the same time, as results received will be mixed.

goto done
}

for {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't need to be a loop


done:
defer func() {
log.Infof("GetAddedLowFeeTickets processed %v tickets in %v waitTime %v",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is common in this codebase but i think intercepting the requests (similar to how i do it in wallet) is a much cleaner and simpler way to keep track of this info

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/decred/dcrwallet/blob/768542b7d2dd1d021c51cf3f07c2c24d46151cd3/rpcserver.go#L215

capture the current time before and after running the handler and log the delta

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using an interceptor would also be a good place to add the deadline to the context

startTime := time.Now()
tickets := make([]*pb.TicketEntry, 0)

// limit the time we take
Copy link
Member

@jrick jrick Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use context.WithTimeout


message TicketEntry {
string TicketAddress = 1;
string TicketHash = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a string instead of bytes?

}()
return &pb.UpdateVotingPrefsResponse{}, nil

return &pb.SetUserVotingPrefsResponse{Processed: processed}, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return a non-nil error if it timed out and the request wasn't processed

@jolan jolan merged commit d7d2a5a into decred:master Nov 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants