diff options
Diffstat (limited to 'simulation')
-rw-r--r-- | simulation/app.go | 9 | ||||
-rw-r--r-- | simulation/constant.go | 2 | ||||
-rw-r--r-- | simulation/kubernetes/config.toml.in | 2 | ||||
-rw-r--r-- | simulation/kubernetes/peer-server.yaml | 8 |
4 files changed, 15 insertions, 6 deletions
diff --git a/simulation/app.go b/simulation/app.go index 89b41a1..0330f07 100644 --- a/simulation/app.go +++ b/simulation/app.go @@ -20,6 +20,7 @@ package simulation import ( "encoding/json" "fmt" + "sync" "time" "github.com/dexon-foundation/dexon-consensus-core/common" @@ -38,6 +39,7 @@ type simApp struct { // uncofirmBlocks stores the blocks whose timestamps are not ready. unconfirmedBlocks map[types.ValidatorID]common.Hashes blockByHash map[common.Hash]*types.Block + blockByHashMutex sync.RWMutex } // newSimApp returns point to a new instance of simApp. @@ -53,6 +55,9 @@ func newSimApp(id types.ValidatorID, Network PeerServerNetwork) *simApp { } func (a *simApp) addBlock(block *types.Block) { + a.blockByHashMutex.Lock() + defer a.blockByHashMutex.Unlock() + a.blockByHash[block.Hash] = block } @@ -74,6 +79,7 @@ func (a *simApp) getAckedBlocks(ackHash common.Hash) (output common.Hashes) { break } } + // All of the Height of unconfirmed blocks are lower than the acked block. if len(output) == 0 { output, a.unconfirmedBlocks[ackBlock.ProposerID] = hashes, common.Hashes{} @@ -89,6 +95,9 @@ 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) { + a.blockByHashMutex.Lock() + defer a.blockByHashMutex.Unlock() + now := time.Now() blocks := make([]*types.Block, len(blockHashes)) for idx := range blockHashes { diff --git a/simulation/constant.go b/simulation/constant.go index 79ef84a..b805118 100644 --- a/simulation/constant.go +++ b/simulation/constant.go @@ -19,5 +19,5 @@ package simulation const ( peerPort = 8080 - msgBufferSize = 256 + msgBufferSize = 2560 ) diff --git a/simulation/kubernetes/config.toml.in b/simulation/kubernetes/config.toml.in index 68008a2..4e4ec0b 100644 --- a/simulation/kubernetes/config.toml.in +++ b/simulation/kubernetes/config.toml.in @@ -4,7 +4,7 @@ title = "DEXON Consensus Simulation Config" num = {{numValidators}} propose_interval_mean = 5e+02 propose_interval_sigma = 3e+01 -max_block = 100 +max_block = 1000 [validator.consensus] phi_ratio = 6.66670024394989e-01 diff --git a/simulation/kubernetes/peer-server.yaml b/simulation/kubernetes/peer-server.yaml index 3a07590..eb8a70e 100644 --- a/simulation/kubernetes/peer-server.yaml +++ b/simulation/kubernetes/peer-server.yaml @@ -41,11 +41,11 @@ spec: - containerPort: 8080 resources: requests: - cpu: 2 - memory: 2Gi + cpu: 4 + memory: 4Gi limits: - cpu: 2 - memory: 2Gi + cpu: 4 + memory: 4Gi env: - name: ROLE value: "peer-server" |