diff options
Diffstat (limited to 'simulation/app.go')
-rw-r--r-- | simulation/app.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/simulation/app.go b/simulation/app.go index 34b53f4..b6851f8 100644 --- a/simulation/app.go +++ b/simulation/app.go @@ -19,6 +19,7 @@ package simulation import ( "fmt" + "time" "github.com/dexon-foundation/dexon-consensus-core/common" "github.com/dexon-foundation/dexon-consensus-core/core/types" @@ -49,13 +50,27 @@ func (a *SimApp) ValidateBlock(b *types.Block) bool { // Deliver is called when blocks are delivered by the total ordering algorithm. func (a *SimApp) Deliver(blocks []*types.Block, early bool) { + now := time.Now() a.Outputs = blocks a.Early = early fmt.Println("OUTPUT", a.ValidatorID, a.Early, a.Outputs) + blockHash := common.Hashes{} + confirmLatency := []time.Duration{} + for _, block := range blocks { blockHash = append(blockHash, block.Hash) + if block.ProposerID == a.ValidatorID { + confirmLatency = append(confirmLatency, + now.Sub(block.Timestamps[a.ValidatorID])) + } + } + + blockList := BlockList{ + ID: a.DeliverID, + BlockHash: blockHash, + ConfirmLatency: confirmLatency, } - a.Network.DeliverBlocks(blockHash, a.DeliverID) + a.Network.DeliverBlocks(blockList) a.DeliverID++ } |