From cc98117df2fd8cef38194fb2a81e08dc3ed4f66d Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 22 May 2020 17:21:37 +0300 Subject: [PATCH] log block validation time --- chain/sub/incoming.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chain/sub/incoming.go b/chain/sub/incoming.go index 3bf42f1c2..2ef9c2718 100644 --- a/chain/sub/incoming.go +++ b/chain/sub/incoming.go @@ -143,6 +143,13 @@ func (bv *BlockValidator) flagPeer(p peer.ID) { } func (bv *BlockValidator) Validate(ctx context.Context, pid peer.ID, msg *pubsub.Message) pubsub.ValidationResult { + // track validation time + begin := time.Now() + defer func() { + end := time.Now() + log.Infof("block validation time: %s", end.Sub(begin)) + }() + stats.Record(ctx, metrics.BlockReceived.M(1)) recordFailure := func(what string) {