Skip to content

Commit 63be43c

Browse files
authored
fix(ledger): use a named type for credential hash (#962)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent d21cc8b commit 63be43c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

internal/test/ledger/ledger.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ func (ls MockLedgerState) StakeRegistration(
5151
) ([]common.StakeRegistrationCertificate, error) {
5252
ret := []common.StakeRegistrationCertificate{}
5353
for _, cert := range ls.MockStakeRegistration {
54-
if string(cert.StakeRegistration.Credential) == string(stakingKey) {
54+
if string(
55+
common.Blake2b224(cert.StakeRegistration.Credential).Bytes(),
56+
) == string(
57+
stakingKey,
58+
) {
5559
ret = append(ret, cert)
5660
}
5761
}

ledger/common/credentials.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ const (
2727
CredentialTypeScriptHash = 1
2828
)
2929

30+
type CredentialHash Blake2b224
31+
3032
type Credential struct {
3133
cbor.StructAsArray
3234
cbor.DecodeStoreCbor
3335
CredType uint
34-
Credential []byte
36+
Credential CredentialHash
3537
}
3638

3739
func (c *Credential) UnmarshalCBOR(data []byte) error {

0 commit comments

Comments
 (0)