Add genesis hash to past

This commit is contained in:
Mark Spanbroek 2021-07-12 15:22:57 +02:00
parent 31ca927b80
commit d6f22399a5
2 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,7 @@ export sets
type
History* = object
genesis*: TxHash
transactions*: HashSet[TxHash]
missingTx*: HashSet[TxHash]
missingAck*: HashSet[AckHash]
@ -55,9 +56,11 @@ func past(store: TxStore, ackHash: AckHash, history: var History) =
history.missingAck.incl(ackHash)
func past*(store: TxStore, hash: TxHash|AckHash): History =
result.genesis = store.genesis
store.past(hash, result)
func past*(store: TxStore, hashes: varargs[AckHash]): History =
result.genesis = store.genesis
for hash in hashes:
store.past(hash, result)

View File

@ -62,6 +62,14 @@ suite "Past transactions and acknowledgements":
check store.past(ack1.hash, ack2.hash).transactions ==
set(genesis.hash, tx1.hash, tx2.hash)
test "past contains the genesis hash":
var store = TxStore.init(genesis)
store.add(tx1, tx3)
store.add(ack3)
check store.past(tx1.hash).genesis == store.genesis
check store.past(tx3.hash).genesis == store.genesis
check store.past(ack3.hash).genesis == store.genesis
suite "Transaction validation":
let alice = PublicKey.alice