diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-09-20 09:09:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 09:09:37 +0800 |
commit | 421d72b2d796195178104a0eb1dedf319ba8664c (patch) | |
tree | f32f15c167989905494eca1891c3240b80dac1d6 /simulation/governance.go | |
parent | 37f117d35c6617e1944d45e001e03813a6a278ed (diff) | |
download | tangerine-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar tangerine-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.gz tangerine-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.bz2 tangerine-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.lz tangerine-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.xz tangerine-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.zst tangerine-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.zip |
Rename validator* to node* (#120)
Diffstat (limited to 'simulation/governance.go')
-rw-r--r-- | simulation/governance.go | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/simulation/governance.go b/simulation/governance.go index 159d536..0f2bbbf 100644 --- a/simulation/governance.go +++ b/simulation/governance.go @@ -29,28 +29,28 @@ import ( // simGovernance is a simulated governance contract implementing the // core.Governance interface. type simGovernance struct { - id types.ValidatorID - lock sync.RWMutex - notarySet map[types.ValidatorID]struct{} - expectedNumValidators int - k int - phiRatio float32 - chainNum uint32 - crs string - dkgComplaint map[uint64][]*types.DKGComplaint - dkgMasterPublicKey map[uint64][]*types.DKGMasterPublicKey - lambda time.Duration - network *network + id types.NodeID + lock sync.RWMutex + notarySet map[types.NodeID]struct{} + expectedNumNodes int + k int + phiRatio float32 + chainNum uint32 + crs string + dkgComplaint map[uint64][]*types.DKGComplaint + dkgMasterPublicKey map[uint64][]*types.DKGMasterPublicKey + lambda time.Duration + network *network } // newSimGovernance returns a new simGovernance instance. func newSimGovernance( - id types.ValidatorID, - numValidators int, consensusConfig config.Consensus) *simGovernance { + id types.NodeID, + numNodes int, consensusConfig config.Consensus) *simGovernance { return &simGovernance{ - id: id, - notarySet: make(map[types.ValidatorID]struct{}), - expectedNumValidators: numValidators, + id: id, + notarySet: make(map[types.NodeID]struct{}), + expectedNumNodes: numNodes, k: consensusConfig.K, phiRatio: consensusConfig.PhiRatio, chainNum: consensusConfig.ChainNum, @@ -66,12 +66,12 @@ func (g *simGovernance) setNetwork(network *network) { } // GetNotarySet returns the current notary set. -func (g *simGovernance) GetNotarySet() map[types.ValidatorID]struct{} { +func (g *simGovernance) GetNotarySet() map[types.NodeID]struct{} { g.lock.RLock() defer g.lock.RUnlock() // Return the cloned notarySet. - ret := make(map[types.ValidatorID]struct{}) + ret := make(map[types.NodeID]struct{}) for k := range g.notarySet { ret[k] = struct{}{} } @@ -90,18 +90,18 @@ func (g *simGovernance) GetConfiguration(blockHeight uint64) *types.Config { } } -// addValidator add a new validator into the simulated governance contract. -func (g *simGovernance) addValidator(vID types.ValidatorID) { +// addNode add a new node into the simulated governance contract. +func (g *simGovernance) addNode(nID types.NodeID) { g.lock.Lock() defer g.lock.Unlock() - if _, exists := g.notarySet[vID]; exists { + if _, exists := g.notarySet[nID]; exists { return } - if len(g.notarySet) == g.expectedNumValidators { - panic(fmt.Errorf("attempt to add validator when ready")) + if len(g.notarySet) == g.expectedNumNodes { + panic(fmt.Errorf("attempt to add node when ready")) } - g.notarySet[vID] = struct{}{} + g.notarySet[nID] = struct{}{} } // AddDKGComplaint adds a DKGComplaint. |