mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-01-04 06:33:11 +00:00
derive Hash type from Block type
This commit is contained in:
parent
de854cbb5f
commit
ea9e1c01f9
@ -1,6 +1,5 @@
|
||||
type Dependencies*[
|
||||
Block,
|
||||
Hash,
|
||||
Identifier,
|
||||
Signature
|
||||
] = object
|
||||
|
||||
@ -84,7 +84,9 @@ func addBlock(validator: Validator, signedBlock: SignedBlock) =
|
||||
|
||||
func parentBlocks*(validator: Validator): auto =
|
||||
mixin id
|
||||
var parents: seq[BlockId[Validator.Dependencies.Hash]]
|
||||
type Block = Validator.Dependencies.Block
|
||||
type BlockId = typeof(Block.default.id)
|
||||
var parents: seq[BlockId]
|
||||
if previous =? validator.rounds.latest.previous:
|
||||
for slot in previous.slots:
|
||||
if slot.proposals.len == 1:
|
||||
@ -93,8 +95,9 @@ func parentBlocks*(validator: Validator): auto =
|
||||
|
||||
func check*(validator: Validator, signed: SignedBlock): auto =
|
||||
mixin id
|
||||
type BlockCheck = checks.BlockCheck[SignedBlock.Dependencies]
|
||||
type BlockId = blocks.BlockId[SignedBlock.Dependencies.Hash]
|
||||
type BlockCheck = checks.BlockCheck[Validator.Dependencies]
|
||||
type Block = Validator.Dependencies.Block
|
||||
type BlockId = typeof(Block.default.id)
|
||||
without member =? validator.committee.membership(signed.signer):
|
||||
return BlockCheck.invalid("block is not signed by a committee member")
|
||||
if member != signed.blck.author:
|
||||
|
||||
@ -11,7 +11,7 @@ type
|
||||
of invalid:
|
||||
reason: string
|
||||
of incomplete:
|
||||
missing: seq[BlockId[Dependencies.Hash]]
|
||||
missing: seq[typeof(Dependencies.Block.default.id)]
|
||||
of correct:
|
||||
blck: CorrectBlock[Dependencies]
|
||||
CorrectBlock*[Dependencies] = distinct SignedBlock[Dependencies]
|
||||
|
||||
@ -11,7 +11,7 @@ type
|
||||
slot: ProposerSlot[Dependencies]
|
||||
signedBlock: SignedBlock[Dependencies]
|
||||
certifiedBy: Voting
|
||||
certificates: seq[BlockId[Dependencies.Hash]]
|
||||
certificates: seq[typeof(Dependencies.Block.default.id)]
|
||||
SlotStatus* {.pure.} = enum
|
||||
undecided
|
||||
skip
|
||||
|
||||
@ -11,7 +11,6 @@ export blck
|
||||
|
||||
type MockDependencies* = Dependencies[
|
||||
MockBlock,
|
||||
MockHash,
|
||||
MockIdentifier,
|
||||
MockSignature
|
||||
]
|
||||
|
||||
@ -4,7 +4,7 @@ import mysticeti/validator/slots
|
||||
|
||||
suite "Proposer Slots":
|
||||
|
||||
type BlockId = mysticeti.BlockId[MockDependencies.Hash]
|
||||
type BlockId = mysticeti.BlockId[MockHash]
|
||||
type SignedBlock = mysticeti.SignedBlock[MockDependencies]
|
||||
type Proposal = slots.Proposal[MockDependencies]
|
||||
type ProposerSlot = slots.ProposerSlot[MockDependencies]
|
||||
|
||||
@ -9,8 +9,8 @@ suite "Validator Network":
|
||||
type Transaction = MockTransaction
|
||||
type Block = MockBlock
|
||||
type SignedBlock = blocks.SignedBlock[MockDependencies]
|
||||
type BlockId = blocks.BlockId[MockDependencies.Hash]
|
||||
type Hash = MockDependencies.Hash
|
||||
type BlockId = blocks.BlockId[MockHash]
|
||||
type Hash = MockHash
|
||||
|
||||
var simulator: NetworkSimulator
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user