mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-01-08 16:43:11 +00:00
keep identity (private key) outside of the validator
This commit is contained in:
parent
456669248f
commit
8caa6e04b8
@ -9,28 +9,27 @@ export slots
|
||||
export checks
|
||||
|
||||
type Validator*[Dependencies] = ref object
|
||||
identity: Dependencies.Identity
|
||||
identifier: Dependencies.Identifier
|
||||
committee: Committee[Dependencies.Identifier]
|
||||
membership: CommitteeMember
|
||||
rounds: Rounds[Dependencies]
|
||||
|
||||
func new*[Dependencies](
|
||||
_: type Validator[Dependencies],
|
||||
identity: Dependencies.Identity,
|
||||
identifier: Dependencies.Identifier,
|
||||
committee: Committee[Dependencies.Identifier]
|
||||
): Validator[Dependencies] =
|
||||
without membership =? committee.membership(identity.identifier):
|
||||
without membership =? committee.membership(identifier):
|
||||
raiseAssert "identity is not a member of the committee"
|
||||
Validator[Dependencies](
|
||||
identity: identity,
|
||||
identifier: identifier,
|
||||
committee: committee,
|
||||
membership: membership,
|
||||
rounds: Rounds[Dependencies].init(committee.size)
|
||||
)
|
||||
|
||||
func identifier*(validator: Validator): auto =
|
||||
mixin identifier
|
||||
validator.identity.identifier
|
||||
validator.identifier
|
||||
|
||||
func membership*(validator: Validator): CommitteeMember =
|
||||
validator.membership
|
||||
|
||||
@ -17,7 +17,7 @@ proc init*(_: type NetworkSimulator, numberOfValidators = 4): NetworkSimulator =
|
||||
let identities = newSeqWith(numberOfValidators, Identity.init())
|
||||
let stakes = identities.mapIt( (it.identifier, 1/numberOfValidators) )
|
||||
let committee = Committee.new(stakes)
|
||||
let validators = identities.mapIt(Validator.new(it, committee))
|
||||
let validators = identities.mapIt(Validator.new(it.identifier, committee))
|
||||
NetworkSimulator(identities: identities, validators: validators)
|
||||
|
||||
func identities*(simulator: NetworkSimulator): seq[Identity] =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user