align field name across `SomeSig`
`ValidatorSig` uses `blob` but `TrustedSig` uses `data`, aligning the names reduces code duplication and improves clarity. It also simplifies `StableContainer` compatibility checks.
This commit is contained in:
parent
3d65bdcb09
commit
6346916224
|
@ -77,7 +77,7 @@ type
|
||||||
BlsResult*[T] = Result[T, cstring]
|
BlsResult*[T] = Result[T, cstring]
|
||||||
|
|
||||||
TrustedSig* = object
|
TrustedSig* = object
|
||||||
data* {.align: 16.}: array[RawSigSize, byte]
|
blob* {.align: 16.}: array[RawSigSize, byte]
|
||||||
|
|
||||||
SomeSig* = TrustedSig | ValidatorSig
|
SomeSig* = TrustedSig | ValidatorSig
|
||||||
|
|
||||||
|
@ -390,12 +390,9 @@ func toRaw*(x: ValidatorPrivKey): array[32, byte] =
|
||||||
# TODO: distinct type - see https://github.com/status-im/nim-blscurve/pull/67
|
# TODO: distinct type - see https://github.com/status-im/nim-blscurve/pull/67
|
||||||
static: doAssert BLS_BACKEND == BLST
|
static: doAssert BLS_BACKEND == BLST
|
||||||
result = SecretKey(x).exportRaw()
|
result = SecretKey(x).exportRaw()
|
||||||
|
|
||||||
template toRaw*(x: ValidatorPubKey | ValidatorSig): auto =
|
|
||||||
x.blob
|
|
||||||
|
|
||||||
template toRaw*(x: TrustedSig): auto =
|
template toRaw*(x: ValidatorPubKey | SomeSig): auto =
|
||||||
x.data
|
x.blob
|
||||||
|
|
||||||
func toHex*(x: BlsCurveType): string =
|
func toHex*(x: BlsCurveType): string =
|
||||||
toHex(toRaw(x))
|
toHex(toRaw(x))
|
||||||
|
@ -507,7 +504,7 @@ template fromSszBytes*(T: type[ValidatorPubKey | ValidatorSig], bytes: openArray
|
||||||
# Logging
|
# Logging
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
func shortLog*(x: ValidatorPubKey | ValidatorSig): string =
|
func shortLog*(x: ValidatorPubKey | SomeSig): string =
|
||||||
## Logging for wrapped BLS types
|
## Logging for wrapped BLS types
|
||||||
## that may contain valid or non-validated data
|
## that may contain valid or non-validated data
|
||||||
byteutils.toHex(x.blob.toOpenArray(0, 3))
|
byteutils.toHex(x.blob.toOpenArray(0, 3))
|
||||||
|
@ -520,9 +517,6 @@ func shortLog*(x: ValidatorPrivKey): string =
|
||||||
## Logging for raw unwrapped BLS types
|
## Logging for raw unwrapped BLS types
|
||||||
"<private key>"
|
"<private key>"
|
||||||
|
|
||||||
func shortLog*(x: TrustedSig): string =
|
|
||||||
byteutils.toHex(x.data.toOpenArray(0, 3))
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue