aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhaoping-ku <haoping.ku@dexon.org>2018-12-03 14:54:17 +0800
committerGitHub <noreply@github.com>2018-12-03 14:54:17 +0800
commit2e119344b3ecddd2cf07094c89249ab631901c4f (patch)
treeded9bc71e725c9cdb7d9e9bc29cb57dd934c3c7c
parent81c3d2d4446b5daee09529f58bc17cad3284edbf (diff)
downloaddexon-consensus-2e119344b3ecddd2cf07094c89249ab631901c4f.tar
dexon-consensus-2e119344b3ecddd2cf07094c89249ab631901c4f.tar.gz
dexon-consensus-2e119344b3ecddd2cf07094c89249ab631901c4f.tar.bz2
dexon-consensus-2e119344b3ecddd2cf07094c89249ab631901c4f.tar.lz
dexon-consensus-2e119344b3ecddd2cf07094c89249ab631901c4f.tar.xz
dexon-consensus-2e119344b3ecddd2cf07094c89249ab631901c4f.tar.zst
dexon-consensus-2e119344b3ecddd2cf07094c89249ab631901c4f.zip
simulation: fix confirm latency (#353)
-rw-r--r--simulation/app.go9
-rw-r--r--simulation/verification.go7
2 files changed, 10 insertions, 6 deletions
diff --git a/simulation/app.go b/simulation/app.go
index 89d76ae..af271e1 100644
--- a/simulation/app.go
+++ b/simulation/app.go
@@ -137,9 +137,14 @@ func (a *simApp) PrepareWitness(height uint64) (types.Witness, error) {
func (a *simApp) TotalOrderingDelivered(
blockHashes common.Hashes, mode uint32) {
fmt.Println("OUTPUT", a.NodeID, mode, blockHashes)
+ latencies := []time.Duration{}
+ for _, h := range blockHashes {
+ latencies = append(latencies, time.Since(a.blockSeen[h]))
+ }
blockList := &BlockList{
- ID: a.DeliverID,
- BlockHash: blockHashes,
+ ID: a.DeliverID,
+ BlockHash: blockHashes,
+ ConfirmLatency: latencies,
}
a.netModule.Report(blockList)
a.DeliverID++
diff --git a/simulation/verification.go b/simulation/verification.go
index f08c73f..a5aad8f 100644
--- a/simulation/verification.go
+++ b/simulation/verification.go
@@ -77,7 +77,7 @@ func (totalOrder *TotalOrderResult) processStatus(blocks BlockList) {
}
// PushBlocks push a BlockList into the TotalOrderResult and return true if
-// there is new blocks ready for verifiy
+// there are new blocks ready for verification.
func (totalOrder *TotalOrderResult) PushBlocks(blocks BlockList) (ready bool) {
totalOrder.processStatus(blocks)
if blocks.ID != totalOrder.curID {
@@ -98,7 +98,7 @@ func (totalOrder *TotalOrderResult) PushBlocks(blocks BlockList) (ready bool) {
return true
}
-// PushTimestamp log the information in the msg.
+// PushTimestamp logs the information in the msg.
func (totalOrder *TotalOrderResult) PushTimestamp(msg timestampMessage) bool {
pushLatency := func(latency *[]time.Duration, t1, t2 time.Time) {
*latency = append(*latency, t2.Sub(t1))
@@ -220,8 +220,7 @@ func VerifyTotalOrder(id types.NodeID,
func LogStatus(peerTotalOrder PeerTotalOrder) {
for nID, totalOrder := range peerTotalOrder {
log.Printf("[Node %s]\n", nID)
- log.Printf(" BPS: %.6f\n",
- totalOrder.CalculateBlocksPerSecond())
+ log.Printf(" BPS: %.6f\n", totalOrder.CalculateBlocksPerSecond())
log.Printf(" Confirm Latency: %.2fms\n",
totalOrder.CalculateAverageConfirmLatency()*1000)
log.Printf(" Confirm Blocks: %v\n", len(totalOrder.status.confirmLatency))