object/user: Add ScriptHash method #199
No reviewers
TrueCloudLab/storage-core-developers
Labels
No labels
P0
P1
P2
P3
good first issue
pool
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-sdk-go#199
Loading…
Reference in a new issue
No description provided.
Delete branch "achuprov/frostfs-sdk-go:feature/198_add_ScriptHash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Close #198
Signed-off-by: Alexander Chuprov a.chuprov@yadro.com
@ -126,0 +126,4 @@
// ScriptHash calculates and returns script hash of ID.
func (x *ID) ScriptHash() (util.Uint160, error) {
ownerAddress := x.EncodeToString()
This implementation was just an example, we could do it more optimally (see
SetScriptHash
implementation)Here we unnecessarily do encode-decode cycle.
Fixed
@ -96,3 +97,3 @@
s := id.EncodeToString()
_, err := base58.Decode(s)
_, err := base58.CheckDecode(s)
How is this change related to the commit?
Fixed
The change wasn't bad, we could just move it to separate commit
But not the goal, anyway.
b7d7dce14d
to7ec38a7c80
7ec38a7c80
to0075d9d807
@ -75,0 +79,4 @@
}
var scriptHash util.Uint160
copy(scriptHash[:], x.w[1:21])
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()
inSetScriptHash()
.So if neo-go are to change the internal representation, this code will break. The one with
Uint160DecodeBytesBE
will not.fixed
0075d9d807
to23666ef311
@ -50,0 +59,4 @@
decodedScriptHash, err := address.StringToUint160(ownerAddress)
require.NoError(t, err)
require.True(t, reflect.DeepEqual(scriptHash, decodedScriptHash))
scriptHash.Equals
?23666ef311
tob0190b809c