mirror of https://github.com/status-im/nim-abc.git
Rename TxOutput.amount -> TxOutput.value
This commit is contained in:
parent
a7ef3b6b34
commit
96908b01b5
|
@ -19,7 +19,7 @@ type
|
||||||
owner: PublicKey
|
owner: PublicKey
|
||||||
TxOutput* = tuple
|
TxOutput* = tuple
|
||||||
owner: PublicKey
|
owner: PublicKey
|
||||||
amount: UInt256
|
value: UInt256
|
||||||
TxHash* = distinct MDigest[256]
|
TxHash* = distinct MDigest[256]
|
||||||
|
|
||||||
func `==`*(a, b: TxHash): bool {.borrow.}
|
func `==`*(a, b: TxHash): bool {.borrow.}
|
||||||
|
@ -60,9 +60,9 @@ func toBytes*(transaction: Transaction): seq[byte] =
|
||||||
result.add(txHash.toBytes)
|
result.add(txHash.toBytes)
|
||||||
result.add(owner.toBytes)
|
result.add(owner.toBytes)
|
||||||
result.add(transaction.outputs.len.uint8)
|
result.add(transaction.outputs.len.uint8)
|
||||||
for (owner, amount) in transaction.outputs:
|
for (owner, value) in transaction.outputs:
|
||||||
result.add(owner.toBytes)
|
result.add(owner.toBytes)
|
||||||
result.add(amount.toBytes)
|
result.add(value.toBytes)
|
||||||
|
|
||||||
func hash*(transaction: Transaction): TxHash =
|
func hash*(transaction: Transaction): TxHash =
|
||||||
TxHash(sha256.digest(transaction.toBytes))
|
TxHash(sha256.digest(transaction.toBytes))
|
||||||
|
|
|
@ -6,10 +6,10 @@ func checkValue(store: TxStore, transaction: Transaction): bool =
|
||||||
for (hash, owner) in transaction.inputs:
|
for (hash, owner) in transaction.inputs:
|
||||||
for output in store[hash].outputs:
|
for output in store[hash].outputs:
|
||||||
if output.owner == owner:
|
if output.owner == owner:
|
||||||
valueIn += output.amount
|
valueIn += output.value
|
||||||
|
|
||||||
for (_, amount) in transaction.outputs:
|
for (_, value) in transaction.outputs:
|
||||||
valueOut += amount
|
valueOut += value
|
||||||
|
|
||||||
valueIn == valueOut
|
valueIn == valueOut
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue