-
Notifications
You must be signed in to change notification settings - Fork 198
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
Delete nil esdt data #2980
Delete nil esdt data #2980
Conversation
func saveESDTData( | ||
userAcnt state.UserAccountHandler, | ||
esdtData *esdt.ESDigitalToken, | ||
key []byte, | ||
marshalizer marshal.Marshalizer, | ||
) error { | ||
isValueZero := esdtData.Value.Cmp(zero) == 0 | ||
if isValueZero && arePropertiesEmpty(esdtData.Properties) { | ||
return userAcnt.DataTrieTracker().SaveKeyValue(key, nil) |
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.
will this remove the key also? or the key remains but with null
value?
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 removes the key.
@@ -265,12 +265,26 @@ func checkFrozeAndPause( | |||
return nil | |||
} | |||
|
|||
func arePropertiesEmpty(properties []byte) bool { | |||
for _, property := range properties { |
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.
could use an early if len(properties) > 0 { return false }
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.
no. as if you do len(make([]byte, 10)) it returns 10
Delete nil esdt data