Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

validation.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_CONSENSUS_VALIDATION_H
7 #define BITCOIN_CONSENSUS_VALIDATION_H
8 
9 #include <string>
10 
12 static const unsigned char REJECT_MALFORMED = 0x01;
13 static const unsigned char REJECT_INVALID = 0x10;
14 static const unsigned char REJECT_OBSOLETE = 0x11;
15 static const unsigned char REJECT_DUPLICATE = 0x12;
16 static const unsigned char REJECT_NONSTANDARD = 0x40;
17 // static const unsigned char REJECT_DUST = 0x41; // part of BIP 61
18 static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;
19 static const unsigned char REJECT_CHECKPOINT = 0x43;
20 
23 private:
24  enum mode_state {
28  } mode;
29  int nDoS;
30  std::string strRejectReason;
31  unsigned int chRejectCode;
33  std::string strDebugMessage;
34 public:
36  bool DoS(int level, bool ret = false,
37  unsigned int chRejectCodeIn=0, const std::string &strRejectReasonIn="",
38  bool corruptionIn=false,
39  const std::string &strDebugMessageIn="") {
40  chRejectCode = chRejectCodeIn;
41  strRejectReason = strRejectReasonIn;
42  corruptionPossible = corruptionIn;
43  strDebugMessage = strDebugMessageIn;
44  if (mode == MODE_ERROR)
45  return ret;
46  nDoS += level;
48  return ret;
49  }
50  bool Invalid(bool ret = false,
51  unsigned int _chRejectCode=0, const std::string &_strRejectReason="",
52  const std::string &_strDebugMessage="") {
53  return DoS(0, ret, _chRejectCode, _strRejectReason, false, _strDebugMessage);
54  }
55  bool Error(const std::string& strRejectReasonIn) {
56  if (mode == MODE_VALID)
57  strRejectReason = strRejectReasonIn;
58  mode = MODE_ERROR;
59  return false;
60  }
61  bool IsValid() const {
62  return mode == MODE_VALID;
63  }
64  bool IsInvalid() const {
65  return mode == MODE_INVALID;
66  }
67  bool IsError() const {
68  return mode == MODE_ERROR;
69  }
70  bool IsInvalid(int &nDoSOut) const {
71  if (IsInvalid()) {
72  nDoSOut = nDoS;
73  return true;
74  }
75  return false;
76  }
77  bool CorruptionPossible() const {
78  return corruptionPossible;
79  }
80  unsigned int GetRejectCode() const { return chRejectCode; }
81  std::string GetRejectReason() const { return strRejectReason; }
82  std::string GetDebugMessage() const { return strDebugMessage; }
83 };
84 
85 #endif // BITCOIN_CONSENSUS_VALIDATION_H
unsigned int chRejectCode
Definition: validation.h:31
static const unsigned char REJECT_INSUFFICIENTFEE
Definition: validation.h:18
enum CValidationState::mode_state mode
bool IsValid() const
Definition: validation.h:61
network rule violation (DoS value may be set)
Definition: validation.h:26
bool DoS(int level, bool ret=false, unsigned int chRejectCodeIn=0, const std::string &strRejectReasonIn="", bool corruptionIn=false, const std::string &strDebugMessageIn="")
Definition: validation.h:36
bool IsInvalid(int &nDoSOut) const
Definition: validation.h:70
bool corruptionPossible
Definition: validation.h:32
static const unsigned char REJECT_INVALID
Definition: validation.h:13
static const unsigned char REJECT_OBSOLETE
Definition: validation.h:14
static const unsigned char REJECT_CHECKPOINT
Definition: validation.h:19
false
Definition: bls_dkg.cpp:168
bool IsInvalid() const
Definition: validation.h:64
static const unsigned char REJECT_NONSTANDARD
Definition: validation.h:16
std::string GetRejectReason() const
Definition: validation.h:81
bool IsError() const
Definition: validation.h:67
static const unsigned char REJECT_DUPLICATE
Definition: validation.h:15
bool Error(const std::string &strRejectReasonIn)
Definition: validation.h:55
Capture information about block/transaction validation.
Definition: validation.h:22
std::string GetDebugMessage() const
Definition: validation.h:82
unsigned int GetRejectCode() const
Definition: validation.h:80
bool CorruptionPossible() const
Definition: validation.h:77
std::string strRejectReason
Definition: validation.h:30
std::string strDebugMessage
Definition: validation.h:33
static const unsigned char REJECT_MALFORMED
"reject" message codes
Definition: validation.h:12
bool Invalid(bool ret=false, unsigned int _chRejectCode=0, const std::string &_strRejectReason="", const std::string &_strDebugMessage="")
Definition: validation.h:50
Released under the MIT license