From 09a0ab086cdafcb27b74e6346efdc8e96ca8145d Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Fri, 10 Aug 2018 15:12:56 +0800 Subject: core: update governance interface and move K into config (#40) --- simulation/app.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'simulation/app.go') diff --git a/simulation/app.go b/simulation/app.go index 2d09f2a..89b41a1 100644 --- a/simulation/app.go +++ b/simulation/app.go @@ -26,8 +26,8 @@ import ( "github.com/dexon-foundation/dexon-consensus-core/core/types" ) -// SimApp is an DEXON app for simulation. -type SimApp struct { +// simApp is an DEXON app for simulation. +type simApp struct { ValidatorID types.ValidatorID Outputs []*types.Block Early bool @@ -40,9 +40,9 @@ type SimApp struct { blockByHash map[common.Hash]*types.Block } -// NewSimApp returns point to a new instance of SimApp. -func NewSimApp(id types.ValidatorID, Network PeerServerNetwork) *SimApp { - return &SimApp{ +// newSimApp returns point to a new instance of simApp. +func newSimApp(id types.ValidatorID, Network PeerServerNetwork) *simApp { + return &simApp{ ValidatorID: id, Network: Network, DeliverID: 0, @@ -52,13 +52,13 @@ func NewSimApp(id types.ValidatorID, Network PeerServerNetwork) *SimApp { } } -func (a *SimApp) addBlock(block *types.Block) { +func (a *simApp) addBlock(block *types.Block) { a.blockByHash[block.Hash] = block } // getAckedBlocks will return all unconfirmed blocks' hash with lower Height // than the block with ackHash. -func (a *SimApp) getAckedBlocks(ackHash common.Hash) (output common.Hashes) { +func (a *simApp) getAckedBlocks(ackHash common.Hash) (output common.Hashes) { // TODO(jimmy-dexon): Why there are some acks never seen? ackBlock, exist := a.blockByHash[ackHash] if !exist { @@ -83,12 +83,12 @@ func (a *SimApp) getAckedBlocks(ackHash common.Hash) (output common.Hashes) { // StronglyAcked is called when a block is strongly acked by DEXON // Reliabe Broadcast algorithm. -func (a *SimApp) StronglyAcked(blockHash common.Hash) { +func (a *simApp) StronglyAcked(blockHash common.Hash) { } // TotalOrderingDeliver is called when blocks are delivered by the total // ordering algorithm. -func (a *SimApp) TotalOrderingDeliver(blockHashes common.Hashes, early bool) { +func (a *simApp) TotalOrderingDeliver(blockHashes common.Hashes, early bool) { now := time.Now() blocks := make([]*types.Block, len(blockHashes)) for idx := range blockHashes { @@ -147,7 +147,7 @@ func (a *SimApp) TotalOrderingDeliver(blockHashes common.Hashes, early bool) { } // DeliverBlock is called when a block in compaction chain is delivered. -func (a *SimApp) DeliverBlock(blockHash common.Hash, timestamp time.Time) { +func (a *simApp) DeliverBlock(blockHash common.Hash, timestamp time.Time) { seenTime, exist := a.blockSeen[blockHash] if !exist { return -- cgit v1.2.3