Suppression helper function.

This commit is contained in:
JoelKatz
2012-11-04 14:39:50 -08:00
parent eb58c6abf1
commit 5134c9d574
3 changed files with 17 additions and 3 deletions

View File

@@ -99,6 +99,7 @@ public:
bool isNew(const uint256& s) { return mSuppressions.addSuppression(s); }
bool isNew(const uint256& s, uint64 p) { return mSuppressions.addSuppressionPeer(s, p); }
bool isNew(const uint256& s, uint64 p, int& f) { return mSuppressions.addSuppressionPeer(s, p, f); }
bool isNewFlag(const uint256& s, int f) { return mSuppressions.setFlag(s, f); }
bool running() { return mTxnDB != NULL; }
bool getSystemTimeOffset(int& offset) { return mSNTPClient.getOffset(offset); }

View File

@@ -58,6 +58,17 @@ bool SuppressionTable::addSuppressionPeer(const uint256& index, uint64 peer)
return created;
}
bool SuppressionTable::addSuppressionPeer(const uint256& index, uint64 peer, int& flags)
{
boost::mutex::scoped_lock sl(mSuppressionMutex);
bool created;
Suppression &s = findCreateEntry(index, created);
s.addPeer(peer);
flags = s.getFlags();
return created;
}
bool SuppressionTable::addSuppressionFlags(const uint256& index, int flag)
{
boost::mutex::scoped_lock sl(mSuppressionMutex);

View File

@@ -14,10 +14,11 @@
DEFINE_INSTANCE(Suppression);
#define SF_RELAYED 0x01
#define SF_SIGBAD 0x02
#define SF_SIGGOOD 0x04
#define SF_RELAYED 0x01 // Has already been relayed to other nodes
#define SF_BAD 0x02 // Signature/format is bad
#define SF_SIGGOOD 0x04 // Signature is good
#define SF_SAVED 0x08
#define SF_RETRY 0x10 // Transaction can be retried
class Suppression : private IS_INSTANCE(Suppression)
{
@@ -61,6 +62,7 @@ public:
bool addSuppression(const uint256& index);
bool addSuppressionPeer(const uint256& index, uint64 peer);
bool addSuppressionPeer(const uint256& index, uint64 peer, int& flags);
bool addSuppressionFlags(const uint256& index, int flag);
bool setFlag(const uint256& index, int flag);