mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
net: use GetTime<T>()
in leftover GetTimeSeconds()
usage
This commit is contained in:
parent
b114718240
commit
8f8e73242d
@ -1901,7 +1901,7 @@ bool CConnman::AttemptToEvictConnection()
|
|||||||
// follow when the incoming connection is from another masternode. When a message other than MNAUTH
|
// follow when the incoming connection is from another masternode. When a message other than MNAUTH
|
||||||
// is received after VERSION/VERACK, the protection is lifted immediately.
|
// is received after VERSION/VERACK, the protection is lifted immediately.
|
||||||
bool isProtected = GetTime<std::chrono::seconds>() - node->m_connected < INBOUND_EVICTION_PROTECTION_TIME;
|
bool isProtected = GetTime<std::chrono::seconds>() - node->m_connected < INBOUND_EVICTION_PROTECTION_TIME;
|
||||||
if (node->nTimeFirstMessageReceived != 0 && !node->fFirstMessageIsMNAUTH) {
|
if (node->nTimeFirstMessageReceived.load() != 0s && !node->fFirstMessageIsMNAUTH) {
|
||||||
isProtected = false;
|
isProtected = false;
|
||||||
}
|
}
|
||||||
// if MNAUTH was valid, the node is always protected (and at the same time not accounted when
|
// if MNAUTH was valid, the node is always protected (and at the same time not accounted when
|
||||||
@ -3754,7 +3754,7 @@ void CConnman::ThreadOpenMasternodeConnections(CDeterministicMNManager& dmnman,
|
|||||||
// we probably connected to it before it became a masternode
|
// we probably connected to it before it became a masternode
|
||||||
// or maybe we are still waiting for mnauth
|
// or maybe we are still waiting for mnauth
|
||||||
(void)ForNode(addr2, [&](CNode* pnode) {
|
(void)ForNode(addr2, [&](CNode* pnode) {
|
||||||
if (pnode->nTimeFirstMessageReceived != 0 && GetTimeSeconds() - pnode->nTimeFirstMessageReceived > 5) {
|
if (pnode->nTimeFirstMessageReceived.load() != 0s && GetTime<std::chrono::seconds>() - pnode->nTimeFirstMessageReceived.load() > 5s) {
|
||||||
// clearly not expecting mnauth to take that long even if it wasn't the first message
|
// clearly not expecting mnauth to take that long even if it wasn't the first message
|
||||||
// we received (as it should normally), disconnect
|
// we received (as it should normally), disconnect
|
||||||
LogPrint(BCLog::NET_NETCONN, "CConnman::%s -- dropping non-mnauth connection to %s, service=%s\n", _func_, proRegTxHash.ToString(), addr2.ToStringAddrPort());
|
LogPrint(BCLog::NET_NETCONN, "CConnman::%s -- dropping non-mnauth connection to %s, service=%s\n", _func_, proRegTxHash.ToString(), addr2.ToStringAddrPort());
|
||||||
|
@ -766,7 +766,7 @@ public:
|
|||||||
const std::chrono::seconds m_connected;
|
const std::chrono::seconds m_connected;
|
||||||
std::atomic<int64_t> nTimeOffset{0};
|
std::atomic<int64_t> nTimeOffset{0};
|
||||||
std::atomic<int64_t> nLastWarningTime{0};
|
std::atomic<int64_t> nLastWarningTime{0};
|
||||||
std::atomic<int64_t> nTimeFirstMessageReceived{0};
|
std::atomic<std::chrono::seconds> nTimeFirstMessageReceived{0s};
|
||||||
std::atomic<bool> fFirstMessageIsMNAUTH{false};
|
std::atomic<bool> fFirstMessageIsMNAUTH{false};
|
||||||
// Address of this peer
|
// Address of this peer
|
||||||
const CAddress addr;
|
const CAddress addr;
|
||||||
|
@ -3936,9 +3936,9 @@ void PeerManagerImpl::ProcessMessage(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pfrom.nTimeFirstMessageReceived == 0) {
|
if (pfrom.nTimeFirstMessageReceived.load() == 0s) {
|
||||||
// First message after VERSION/VERACK
|
// First message after VERSION/VERACK
|
||||||
pfrom.nTimeFirstMessageReceived = GetTimeSeconds();
|
pfrom.nTimeFirstMessageReceived = GetTime<std::chrono::seconds>();
|
||||||
pfrom.fFirstMessageIsMNAUTH = msg_type == NetMsgType::MNAUTH;
|
pfrom.fFirstMessageIsMNAUTH = msg_type == NetMsgType::MNAUTH;
|
||||||
// Note: do not break the flow here
|
// Note: do not break the flow here
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user