@@ -257,15 +257,15 @@ struct CBlockReject {
257
257
*/
258
258
struct CNodeState {
259
259
// ! The peer's address
260
- CService address;
260
+ const CService address;
261
261
// ! Whether we have a fully established connection.
262
262
bool fCurrentlyConnected ;
263
263
// ! Accumulated misbehaviour score for this peer.
264
264
int nMisbehavior;
265
265
// ! Whether this peer should be disconnected and banned (unless whitelisted).
266
266
bool fShouldBan ;
267
267
// ! String name of this peer (debugging/logging purposes).
268
- std::string name;
268
+ const std::string name;
269
269
// ! List of asynchronously-determined block rejections to notify this peer about.
270
270
std::vector<CBlockReject> rejects;
271
271
// ! The best known block we know this peer has announced.
@@ -309,7 +309,7 @@ struct CNodeState {
309
309
*/
310
310
bool fSupportsDesiredCmpctVersion ;
311
311
312
- CNodeState () {
312
+ CNodeState (CAddress addrIn, std::string addrNameIn) : address(addrIn), name(addrNameIn ) {
313
313
fCurrentlyConnected = false ;
314
314
nMisbehavior = 0 ;
315
315
fShouldBan = false ;
@@ -355,10 +355,10 @@ void UpdatePreferredDownload(CNode* node, CNodeState* state)
355
355
}
356
356
357
357
void InitializeNode (NodeId nodeid, const CNode *pnode) {
358
+ CAddress addr = pnode->addr ;
359
+ std::string addrName = pnode->addrName ;
358
360
LOCK (cs_main);
359
- CNodeState &state = mapNodeState.insert (std::make_pair (nodeid, CNodeState ())).first ->second ;
360
- state.name = pnode->addrName ;
361
- state.address = pnode->addr ;
361
+ mapNodeState.emplace_hint (mapNodeState.end (), std::piecewise_construct, std::forward_as_tuple (nodeid), std::forward_as_tuple (addr, std::move (addrName)));
362
362
}
363
363
364
364
void FinalizeNode (NodeId nodeid, bool & fUpdateConnectionTime ) {
0 commit comments