diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-08-10 15:12:56 +0800 |
---|---|---|
committer | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-10 15:12:56 +0800 |
commit | 09a0ab086cdafcb27b74e6346efdc8e96ca8145d (patch) | |
tree | c14bda316a48c94e5300b5799f152a82f0594558 /simulation/app.go | |
parent | 03917cdfa1f762849541e1bed31394340ed1f957 (diff) | |
download | dexon-consensus-09a0ab086cdafcb27b74e6346efdc8e96ca8145d.tar dexon-consensus-09a0ab086cdafcb27b74e6346efdc8e96ca8145d.tar.gz dexon-consensus-09a0ab086cdafcb27b74e6346efdc8e96ca8145d.tar.bz2 dexon-consensus-09a0ab086cdafcb27b74e6346efdc8e96ca8145d.tar.lz dexon-consensus-09a0ab086cdafcb27b74e6346efdc8e96ca8145d.tar.xz dexon-consensus-09a0ab086cdafcb27b74e6346efdc8e96ca8145d.tar.zst dexon-consensus-09a0ab086cdafcb27b74e6346efdc8e96ca8145d.zip |
core: update governance interface and move K into config (#40)
Diffstat (limited to 'simulation/app.go')
-rw-r--r-- | simulation/app.go | 20 |
1 files changed, 10 insertions, 10 deletions
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 |