-
Notifications
You must be signed in to change notification settings - Fork 145
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
feat(wallet): query incremental timeout #1395
Conversation
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.
for create context not required to call context.WithoutCancel
.
ctx := context.WithoutCancel(context.Background())
wallet/client.go
Outdated
data, err := trx.Bytes() | ||
if err != nil { | ||
return hash.UndefHash, err | ||
} | ||
res, err := c.transactionClient.BroadcastTransaction(c.ctx, | ||
res, err := c.transactionClient.BroadcastTransaction(ctx, |
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.
Important things is gRPC method BroadcastTransaction
should pass context to lower layers to stop process.
When you call gRPC method make a go routine in background to processing then your context send signal cancel base on timeout, process don't canceled in background.
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.
What should we do to cancel it on background? also, why it won't cancel in background when the timeout reaches?
I'm calling WithTimeout, not WithCancel. |
line 29 |
this line is not included in this PR, let me update it. |
@Ja7ad fixed. |
wallet/client.go
Outdated
@@ -76,7 +78,10 @@ func (c *grpcClient) getBlockchainInfo() (*pactus.GetBlockchainInfoResponse, err | |||
return nil, err | |||
} | |||
|
|||
info, err := c.blockchainClient.GetBlockchainInfo(c.ctx, | |||
ctx, cancel := context.WithTimeout(c.ctx, time.Second*5) |
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.
Please no Kay, Please don't repeat yourself!
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.
It seems this way of handling the issue it not correct based on @Ja7ad review. once we find the correct way I'll cleanly handle the code. this PR needs change.
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.
@kehiy This method is not correct to solve the problem and I will implement another method to solve the problem. |
Description
This PR creates a time-out for querying data from gRPC on the wallet. we set a timeout for 5 seconds where the default is 30 seconds. we can make sure a slow RPC won't slow down the proccess.