Skip to content

Conversation

@UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Sep 25, 2016

Turned out that current implementation doesn't really help to mitigate abuse - when connection is closed CNode object is destroyed and removed from nodes vector meaning that all "fulfilled" info is gone too. Such info wasn't preserved on wallet shutdown either so client wasn't able to prevent banning of itself by other nodes. Basically the whole thing wasn't working.

This PR implements a separate manager for fulfilled requests CNetFulfilledRequestManager which fixes issues described above. This also removes testnet/mainnet specific logic for such cases by introducing additional chain param nFulfilledRequestExpireTime (60 minutes for mainnet, 5 minutes for testnet).

Copy link

@tgflynn tgflynn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for a couple of minor points.

utACK

return it != mapFulfilledRequests.end() &&
it->second.find(strRequest) != it->second.end() &&
it->second[strRequest] > GetTime();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does 2 lookups on the strRequest map when one would suffice.

{
LOCK(cs_mapFulfilledRequests);
mapFulfilledRequests[addr][strRequest] = GetTime() + Params().FulfilledRequestExpireTime();
}
Copy link

@tgflynn tgflynn Sep 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

std::string ToString() const;
};

#endif
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to add a private do nothing copy constructor and assignment operator to prevent copying this object, since copying the mutex would probably not be good.

@UdjinM6 UdjinM6 merged commit b855766 into dashpay:v0.12.1.x Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants