mirror of
https://github.com/logos-storage/logos-storage-nim-validator.git
synced 2026-01-03 14:03:07 +00:00
convert transaction to string
This commit is contained in:
parent
0fff583d58
commit
ad3cfdbec5
@ -12,3 +12,5 @@ import ./blocks/hashing
|
||||
|
||||
export hashing.hash
|
||||
export hashing.id
|
||||
export hashing.`==`
|
||||
export hashing.`$`
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from pkg/mysticeti import CommitteeMember, `==`
|
||||
from pkg/mysticeti import CommitteeMember, `==`, `$`
|
||||
import ../basics
|
||||
import ../transaction
|
||||
import ../hashing
|
||||
@ -6,6 +6,7 @@ import ./blockid
|
||||
|
||||
export mysticeti.CommitteeMember
|
||||
export mysticeti.`==`
|
||||
export mysticeti.`$`
|
||||
|
||||
type Block* = ref object
|
||||
author*: CommitteeMember
|
||||
|
||||
@ -16,3 +16,9 @@ func id*(b: Block): BlockId =
|
||||
b.round,
|
||||
hash(b)
|
||||
)
|
||||
|
||||
func `==`*(a, b: Block): bool =
|
||||
a.hash == b.hash
|
||||
|
||||
func `$`*(b: Block): string =
|
||||
$b.id
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import pkg/nimcrypto/sha2
|
||||
import pkg/nimcrypto/hash
|
||||
|
||||
export hash.`$`
|
||||
|
||||
type Hash* = MDigest[256]
|
||||
|
||||
func hash*(_: type Hash, bytes: openArray[byte]): Hash =
|
||||
|
||||
@ -73,3 +73,12 @@ func `==`*(a, b: Transaction): bool =
|
||||
a.proof == b.proof
|
||||
of TransactionKind.missingProof:
|
||||
true
|
||||
|
||||
func `$`*(transaction: Transaction): string =
|
||||
result &= "Transaction("
|
||||
result &= "version: " & $transaction.version
|
||||
result &= ", kind: " & $transaction.kind
|
||||
result &= ", proofInput: " & $transaction.proofInput
|
||||
if transaction.kind == TransactionKind.storageProof:
|
||||
result &= ", proof: " & $transaction.proof
|
||||
result &= ")"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user