Skip to content

Rewrite fulfilled requests handling#1040

Merged
UdjinM6 merged 1 commit into
dashpay:v0.12.1.xfrom
UdjinM6:RefFulfilledRequests
Sep 27, 2016
Merged

Rewrite fulfilled requests handling#1040
UdjinM6 merged 1 commit into
dashpay:v0.12.1.xfrom
UdjinM6:RefFulfilledRequests

Conversation

@UdjinM6
Copy link
Copy Markdown

@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
Copy Markdown

@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

Comment thread src/netfulfilledman.cpp
return it != mapFulfilledRequests.end() &&
it->second.find(strRequest) != it->second.end() &&
it->second[strRequest] > GetTime();
}
Copy link
Copy Markdown

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.

Comment thread src/netfulfilledman.cpp
{
LOCK(cs_mapFulfilledRequests);
mapFulfilledRequests[addr][strRequest] = GetTime() + Params().FulfilledRequestExpireTime();
}
Copy link
Copy Markdown

@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.

👍

Comment thread src/netfulfilledman.h
std::string ToString() const;
};

#endif
Copy link
Copy Markdown

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