object/user: Add ScriptHash method #199

Merged
fyrchik merged 1 commit from achuprov/frostfs-sdk-go:feature/198_add_ScriptHash into master 2024-01-26 14:10:13 +00:00
Member

Close #198

Signed-off-by: Alexander Chuprov a.chuprov@yadro.com

Close #198 Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
fyrchik reviewed 2024-01-17 11:07:01 +00:00
user/id.go Outdated
@ -126,0 +126,4 @@
// ScriptHash calculates and returns script hash of ID.
func (x *ID) ScriptHash() (util.Uint160, error) {
ownerAddress := x.EncodeToString()
Owner

This implementation was just an example, we could do it more optimally (see SetScriptHash implementation)
Here we unnecessarily do encode-decode cycle.

This implementation was just an example, we could do it more optimally (see `SetScriptHash` implementation) Here we unnecessarily do encode-decode cycle.
Author
Member

Fixed

Fixed
fyrchik marked this conversation as resolved
user/id_test.go Outdated
@ -96,3 +97,3 @@
s := id.EncodeToString()
_, err := base58.Decode(s)
_, err := base58.CheckDecode(s)
Owner

How is this change related to the commit?

How is this change related to the commit?
Author
Member

Fixed

Fixed
Owner

The change wasn't bad, we could just move it to separate commit
But not the goal, anyway.

The change wasn't bad, we could just move it to separate commit But not the goal, anyway.
fyrchik marked this conversation as resolved
achuprov force-pushed feature/198_add_ScriptHash from b7d7dce14d to 7ec38a7c80 2024-01-17 14:11:34 +00:00 Compare
achuprov force-pushed feature/198_add_ScriptHash from 7ec38a7c80 to 0075d9d807 2024-01-17 14:27:43 +00:00 Compare
achuprov requested review from storage-core-committers 2024-01-17 14:54:44 +00:00
achuprov requested review from storage-core-developers 2024-01-17 14:54:47 +00:00
fyrchik approved these changes 2024-01-17 18:31:12 +00:00
user/id.go Outdated
@ -75,0 +79,4 @@
}
var scriptHash util.Uint160
copy(scriptHash[:], x.w[1:21])
Owner

It is better to use decoders from https://github.com/nspcc-dev/neo-go/blob/master/pkg/util/uint160.go
There are LE+BE representations, and we use BytesBE() in SetScriptHash().
So if neo-go are to change the internal representation, this code will break. The one with Uint160DecodeBytesBE will not.

It is better to use decoders from https://github.com/nspcc-dev/neo-go/blob/master/pkg/util/uint160.go There are LE+BE representations, and we use `BytesBE()` in `SetScriptHash()`. So if neo-go are to change the internal representation, this code will break. The one with `Uint160DecodeBytesBE` will not.
Author
Member

fixed

fixed
achuprov force-pushed feature/198_add_ScriptHash from 0075d9d807 to 23666ef311 2024-01-26 10:27:33 +00:00 Compare
fyrchik reviewed 2024-01-26 10:30:33 +00:00
user/id_test.go Outdated
@ -50,0 +59,4 @@
decodedScriptHash, err := address.StringToUint160(ownerAddress)
require.NoError(t, err)
require.True(t, reflect.DeepEqual(scriptHash, decodedScriptHash))
Owner

scriptHash.Equals?

`scriptHash.Equals`?
achuprov force-pushed feature/198_add_ScriptHash from 23666ef311 to b0190b809c 2024-01-26 11:42:08 +00:00 Compare
fyrchik approved these changes 2024-01-26 14:09:23 +00:00
fyrchik merged commit 65b4525b3b into master 2024-01-26 14:10:13 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-sdk-go#199
No description provided.