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

RegisterNonce for waiting and view function #2305

Merged
merged 7 commits into from
Sep 24, 2020

Conversation

sasurobert
Copy link
Contributor

RegisterNonce for waiting and view function.
This code is backward compatible if stake was not enabled - after that it is not. Should be merged before enabling staking.

return vmcommon.UserError
}

stakedData, err := r.getOrCreateRegisteredData(element.BLSPublicKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

getOrCreate? Shouldn't have been just get?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is ok. it shouldn't happen to create here - only bad programming

iulianpascalau
iulianpascalau previously approved these changes Sep 21, 2020
iulianpascalau
iulianpascalau previously approved these changes Sep 23, 2020
func (stp *stakingToPeer) getStorageFromAccount(userAcc state.UserAccountHandler, key []byte) []byte {
value, err := userAcc.DataTrieTracker().RetrieveValue(key)
if err != nil {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

log.Trace the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is log traced in retrievevalue.

nextKey := make([]byte, len(waitingElementKey))
copy(nextKey, prevElement.NextKey)
for len(nextKey) != 0 {
for len(nextKey) != 0 && index <= waitingListHead.Length {
Copy link
Contributor

Choose a reason for hiding this comment

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

index < waitingListHead.Length ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Index starts from 1

index := uint32(1)
nextKey := make([]byte, len(waitingListHead.FirstKey))
copy(nextKey, waitingListHead.FirstKey)
for len(nextKey) != 0 && index <= waitingListHead.Length {
Copy link
Contributor

Choose a reason for hiding this comment

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

index < waitingListHead.Length ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Index starts from 1

@@ -1255,7 +1255,7 @@ func (r *stakingSC) getBLSKeyStatus(args *vmcommon.ContractCallInput) vmcommon.R
return vmcommon.Ok
}
if stakedData.Waiting {
r.eei.Finish([]byte("waiting"))
r.eei.Finish([]byte("queued"))
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

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

System test passed.

@LucianMincu LucianMincu merged commit 7e29ed5 into development Sep 24, 2020
@LucianMincu LucianMincu deleted the view-func-waiting-list-data branch September 24, 2020 09:41
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.

None yet

4 participants