@@ -742,6 +742,10 @@ PeerMsgRet CInstantSendManager::ProcessMessage(const CNode& pfrom, PeerManager&
742
742
return {};
743
743
}
744
744
745
+ bool ShouldReportISLockTiming () {
746
+ return g_stats_client->active () || LogAcceptDebug (BCLog::INSTANTSEND);
747
+ }
748
+
745
749
PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock (const CNode& pfrom, PeerManager& peerman,
746
750
const llmq::CInstantSendLockPtr& islock)
747
751
{
@@ -775,16 +779,22 @@ PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock(const CNode& pfrom
775
779
LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: received islock, peer=%d\n " , __func__,
776
780
islock->txid .ToString (), hash.ToString (), pfrom.GetId ());
777
781
778
- auto time_diff = [&] () -> int64_t {
779
- LOCK (cs_timingsTxSeen);
780
- if (auto it = timingsTxSeen.find (islock->txid ); it != timingsTxSeen.end ()) {
781
- // This is the normal case where we received the TX before the islock
782
- return GetTimeMillis () - it->second ;
783
- }
784
- // But if we received the islock and don't know when we got the tx, then say 0, to indicate we received the islock first.
785
- return 0 ;
786
- }();
787
- ::g_stats_client->timing (" islock_ms" , time_diff);
782
+ if (ShouldReportISLockTiming ()) {
783
+ auto time_diff = [&] () -> int64_t {
784
+ LOCK (cs_timingsTxSeen);
785
+ if (auto it = timingsTxSeen.find (islock->txid ); it != timingsTxSeen.end ()) {
786
+ // This is the normal case where we received the TX before the islock
787
+ auto diff = GetTimeMillis () - it->second ;
788
+ timingsTxSeen.erase (it);
789
+ return diff;
790
+ }
791
+ // But if we received the islock and don't know when we got the tx, then say 0, to indicate we received the islock first.
792
+ return 0 ;
793
+ }();
794
+ ::g_stats_client->timing (" islock_ms" , time_diff);
795
+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock took %dms\n " , __func__,
796
+ islock->txid .ToString (), time_diff);
797
+ }
788
798
789
799
LOCK (cs_pendingLocks);
790
800
pendingInstantSendLocks.emplace (hash, std::make_pair (pfrom.GetId (), islock));
@@ -1180,7 +1190,7 @@ void CInstantSendManager::AddNonLockedTx(const CTransactionRef& tx, const CBlock
1180
1190
}
1181
1191
}
1182
1192
1183
- {
1193
+ if ( ShouldReportISLockTiming ()) {
1184
1194
LOCK (cs_timingsTxSeen);
1185
1195
// Only insert the time the first time we see the tx, as we sometimes try to resign
1186
1196
if (auto it = timingsTxSeen.find (tx->GetHash ()); it == timingsTxSeen.end ()) {
0 commit comments