-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Cleanup - Fix bug with stop endpoint & add object type to get objects #892
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.
LGTM
sui/src/rest_server.rs
Outdated
// Taking state object without returning ownership | ||
let mut state = server_context.server_state.lock().await; | ||
let state = state.as_mut().ok_or_else(server_state_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.
why the extra braces??
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.
So that the initial lock on the server_state
will clear when it goes out of scope. Then I can set it to None. Not sure if there is better way to do this?
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.
I see, In that case we can use take()
instead of as_mut()
here, then we can remove the brace and don't need to set the context to None afterward
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.
Now I can use take()
properly, nice!
…ystenLabs#892) Fixes a bug where the primary would panic if an RPC comes in while a node is shutting down. Instead this patch just returns an error to requester. Fixes: MystenLabs#891
Few cleanup items here
/sui/stop
endpoint was not working properly because server_state needed to be cleared so you can run /genesis & /start again.Make
/objects
a little bit more useful by adding the object type as part of the return. i.e.