Skip to content

Commit

Permalink
net: make CNode::m_prefer_evict const
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtowns committed Sep 1, 2022
1 parent d394156 commit 0a7fc42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1030,9 +1030,9 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
inbound_onion,
CNodeOptions{
.permission_flags = permissionFlags,
.prefer_evict = discouraged,
});
pnode->AddRef();
pnode->m_prefer_evict = discouraged;
m_msgproc->InitializeNode(*pnode, nodeServices);

LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString());
Expand Down Expand Up @@ -2734,6 +2734,7 @@ CNode::CNode(NodeId idIn,
addrBind{addrBindIn},
m_addr_name{addrNameIn.empty() ? addr.ToStringIPPort() : addrNameIn},
m_inbound_onion{inbound_onion},
m_prefer_evict{node_opts.prefer_evict},
nKeyedNetGroup{nKeyedNetGroupIn},
id{idIn},
nLocalHostNonce{nLocalHostNonceIn},
Expand Down
3 changes: 2 additions & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ struct CNodeOptions
{
NetPermissionFlags permission_flags = NetPermissionFlags::None;
std::unique_ptr<i2p::sam::Session> i2p_sam_session = nullptr;
bool prefer_evict = false;
};

/** Information about a peer */
Expand Down Expand Up @@ -399,7 +400,7 @@ class CNode
* from the wire. This cleaned string can safely be logged or displayed.
*/
std::string cleanSubVer GUARDED_BY(m_subver_mutex){};
bool m_prefer_evict{false}; // This peer is preferred for eviction. (treated as const)
const bool m_prefer_evict{false}; // This peer is preferred for eviction.
bool HasPermission(NetPermissionFlags permission) const {
return NetPermissions::HasFlag(m_permissionFlags, permission);
}
Expand Down

0 comments on commit 0a7fc42

Please sign in to comment.