Skip to content

Commit 0d4cc69

Browse files
Add duplicated p2p event logging and counting in tx pool latency analysis
1 parent d107976 commit 0d4cc69

File tree

1 file changed

+11
-1
lines changed
  • pkg/coordinator/tasks/tx_pool_latency_analysis

1 file changed

+11
-1
lines changed

pkg/coordinator/tasks/tx_pool_latency_analysis/task.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func (t *Task) Execute(ctx context.Context) error {
132132
startTime := time.Now()
133133
isFailed := false
134134
sentTxCount := 0
135+
duplicatedP2PEventCount := 0
135136

136137
// Start generating and sending transactions
137138
go func() {
@@ -240,11 +241,18 @@ func (t *Task) Execute(ctx context.Context) error {
240241
isFailed = true
241242
return
242243
}
244+
245+
// log the duplicated p2p events, and count duplicated p2p events
246+
if latenciesMus[tx_index] != 0 {
247+
t.logger.Warnf("Duplicated p2p event: %s", tx.Hash().String())
248+
duplicatedP2PEventCount++
249+
}
250+
243251
latenciesMus[tx_index] = time.Since(txStartTime[tx_index]).Microseconds()
244252
receivedEvents++
245253

246254
if receivedEvents%t.config.MeasureInterval == 0 {
247-
t.logger.Infof("Received %d p2p events", sentTxCount)
255+
t.logger.Infof("Received %d p2p events", receivedEvents)
248256
}
249257
}
250258

@@ -320,6 +328,7 @@ func (t *Task) Execute(ctx context.Context) error {
320328
t.ctx.Outputs.SetVar("tx_count", totNumberOfTxes)
321329
t.ctx.Outputs.SetVar("min_latency_mus", minLatency)
322330
t.ctx.Outputs.SetVar("max_latency_mus", maxLatency)
331+
t.ctx.Outputs.SetVar("duplicated_p2p_event_count", duplicatedP2PEventCount)
323332

324333
t.ctx.SetResult(types.TaskResultSuccess)
325334

@@ -328,6 +337,7 @@ func (t *Task) Execute(ctx context.Context) error {
328337
"min_latency_mus": minLatency,
329338
"max_latency_mus": maxLatency,
330339
"tx_pool_latency_hdr_plot": plot,
340+
"duplicated_p2p_event_count": duplicatedP2PEventCount,
331341
}
332342

333343
outputsJSON, _ := json.Marshal(outputs)

0 commit comments

Comments
 (0)