aboutsummaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-11-10 17:11:39 -0800
committerGavin Andresen <gavinandresen@gmail.com>2013-11-10 17:11:39 -0800
commit16d5f2c5e0a7276fb2b09d8dd51b7bac2753c4cc (patch)
treee2abbe951c7b5533452ed8459c6bf7539c5caab7 /src/main.h
parent3a6faabecf719633481253a0d2f874494ad126a5 (diff)
parent69aada346f74c978b5d8be59a5d7c79be966ef8c (diff)
Merge pull request #3185 from gavinandresen/reject
Reject p2p message
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/main.h b/src/main.h
index d717802618..460929d624 100644
--- a/src/main.h
+++ b/src/main.h
@@ -67,6 +67,16 @@ static const int fHaveUPnP = true;
static const int fHaveUPnP = false;
#endif
+/** "reject" message codes **/
+static const unsigned char REJECT_MALFORMED = 0x01;
+static const unsigned char REJECT_INVALID = 0x10;
+static const unsigned char REJECT_OBSOLETE = 0x11;
+static const unsigned char REJECT_DUPLICATE = 0x12;
+static const unsigned char REJECT_NONSTANDARD = 0x40;
+static const unsigned char REJECT_DUST = 0x41;
+static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;
+static const unsigned char REJECT_CHECKPOINT = 0x43;
+
extern CScript COINBASE_FLAGS;
@@ -926,19 +936,26 @@ private:
MODE_ERROR, // run-time error
} mode;
int nDoS;
+ std::string strRejectReason;
+ unsigned char chRejectCode;
bool corruptionPossible;
public:
CValidationState() : mode(MODE_VALID), nDoS(0) {}
- bool DoS(int level, bool ret = false, bool corruptionIn = false) {
+ bool DoS(int level, bool ret = false,
+ unsigned char chRejectCodeIn=0, std::string strRejectReasonIn="",
+ bool corruptionIn=false) {
+ chRejectCode = chRejectCodeIn;
+ strRejectReason = strRejectReasonIn;
+ corruptionPossible = corruptionIn;
if (mode == MODE_ERROR)
return ret;
nDoS += level;
mode = MODE_INVALID;
- corruptionPossible = corruptionIn;
return ret;
}
- bool Invalid(bool ret = false) {
- return DoS(0, ret);
+ bool Invalid(bool ret = false,
+ unsigned char _chRejectCode=0, std::string _strRejectReason="") {
+ return DoS(0, ret, _chRejectCode, _strRejectReason);
}
bool Error() {
mode = MODE_ERROR;
@@ -967,6 +984,8 @@ public:
bool CorruptionPossible() {
return corruptionPossible;
}
+ unsigned char GetRejectCode() const { return chRejectCode; }
+ std::string GetRejectReason() const { return strRejectReason; }
};
/** An in-memory indexed chain of blocks. */