Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
defunctec
crown-core
Commits
f339fff8
Commit
f339fff8
authored
10 years ago
by
jtimon
Committed by
Jorge Timón
9 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Consensus: MOVEONLY: Move CValidationState from main consensus/validation
parent
635b17ac
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
src/Makefile.am
+1
-0
src/Makefile.am
src/consensus/validation.h
+80
-0
src/consensus/validation.h
src/init.cpp
+1
-0
src/init.cpp
src/main.cpp
+1
-0
src/main.cpp
src/main.h
+0
-69
src/main.h
src/miner.cpp
+1
-0
src/miner.cpp
src/rpcblockchain.cpp
+2
-0
src/rpcblockchain.cpp
src/rpcmining.cpp
+1
-0
src/rpcmining.cpp
src/rpcrawtransaction.cpp
+2
-1
src/rpcrawtransaction.cpp
src/test/checkblock_tests.cpp
+2
-7
src/test/checkblock_tests.cpp
src/test/miner_tests.cpp
+1
-0
src/test/miner_tests.cpp
src/test/sighash_tests.cpp
+4
-3
src/test/sighash_tests.cpp
src/test/transaction_tests.cpp
+2
-1
src/test/transaction_tests.cpp
src/txmempool.cpp
+1
-0
src/txmempool.cpp
src/wallet/wallet.cpp
+1
-0
src/wallet/wallet.cpp
src/wallet/walletdb.cpp
+1
-0
src/wallet/walletdb.cpp
with
101 additions
and
81 deletions
+101
-81
src/Makefile.am
View file @
f339fff8
...
...
@@ -92,6 +92,7 @@ BITCOIN_CORE_H = \
compressor.h
\
consensus/consensus.h
\
consensus/params.h
\
consensus/validation.h
\
core_io.h
\
eccryptoverify.h
\
ecwrapper.h
\
...
...
This diff is collapsed.
Click to expand it.
src/consensus/validation.h
0 → 100644
View file @
f339fff8
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CONSENSUS_VALIDATION_H
#define BITCOIN_CONSENSUS_VALIDATION_H
#include <string>
/** "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
;
/** Capture information about block/transaction validation */
class
CValidationState
{
private:
enum
mode_state
{
MODE_VALID
,
//! everything ok
MODE_INVALID
,
//! network rule violation (DoS value may be set)
MODE_ERROR
,
//! run-time error
}
mode
;
int
nDoS
;
std
::
string
strRejectReason
;
unsigned
char
chRejectCode
;
bool
corruptionPossible
;
public:
CValidationState
()
:
mode
(
MODE_VALID
),
nDoS
(
0
),
chRejectCode
(
0
),
corruptionPossible
(
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
;
return
ret
;
}
bool
Invalid
(
bool
ret
=
false
,
unsigned
char
_chRejectCode
=
0
,
std
::
string
_strRejectReason
=
""
)
{
return
DoS
(
0
,
ret
,
_chRejectCode
,
_strRejectReason
);
}
bool
Error
(
std
::
string
strRejectReasonIn
=
""
)
{
if
(
mode
==
MODE_VALID
)
strRejectReason
=
strRejectReasonIn
;
mode
=
MODE_ERROR
;
return
false
;
}
bool
IsValid
()
const
{
return
mode
==
MODE_VALID
;
}
bool
IsInvalid
()
const
{
return
mode
==
MODE_INVALID
;
}
bool
IsError
()
const
{
return
mode
==
MODE_ERROR
;
}
bool
IsInvalid
(
int
&
nDoSOut
)
const
{
if
(
IsInvalid
())
{
nDoSOut
=
nDoS
;
return
true
;
}
return
false
;
}
bool
CorruptionPossible
()
const
{
return
corruptionPossible
;
}
unsigned
char
GetRejectCode
()
const
{
return
chRejectCode
;
}
std
::
string
GetRejectReason
()
const
{
return
strRejectReason
;
}
};
#endif // BITCOIN_CONSENSUS_VALIDATION_H
This diff is collapsed.
Click to expand it.
src/init.cpp
View file @
f339fff8
...
...
@@ -13,6 +13,7 @@
#include "amount.h"
#include "checkpoints.h"
#include "compat/sanity.h"
#include "consensus/validation.h"
#include "key.h"
#include "main.h"
#include "miner.h"
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
View file @
f339fff8
...
...
@@ -11,6 +11,7 @@
#include "chainparams.h"
#include "checkpoints.h"
#include "checkqueue.h"
#include "consensus/validation.h"
#include "init.h"
#include "merkleblock.h"
#include "net.h"
...
...
This diff is collapsed.
Click to expand it.
src/main.h
View file @
f339fff8
...
...
@@ -89,16 +89,6 @@ static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
/** Maximum length of reject messages. */
static
const
unsigned
int
MAX_REJECT_MESSAGE_LENGTH
=
111
;
/** "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
;
struct
BlockHasher
{
size_t
operator
()(
const
uint256
&
hash
)
const
{
return
hash
.
GetCheapHash
();
}
...
...
@@ -457,65 +447,6 @@ public:
}
};
/** Capture information about block/transaction validation */
class
CValidationState
{
private:
enum
mode_state
{
MODE_VALID
,
//! everything ok
MODE_INVALID
,
//! network rule violation (DoS value may be set)
MODE_ERROR
,
//! run-time error
}
mode
;
int
nDoS
;
std
::
string
strRejectReason
;
unsigned
char
chRejectCode
;
bool
corruptionPossible
;
public:
CValidationState
()
:
mode
(
MODE_VALID
),
nDoS
(
0
),
chRejectCode
(
0
),
corruptionPossible
(
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
;
return
ret
;
}
bool
Invalid
(
bool
ret
=
false
,
unsigned
char
_chRejectCode
=
0
,
std
::
string
_strRejectReason
=
""
)
{
return
DoS
(
0
,
ret
,
_chRejectCode
,
_strRejectReason
);
}
bool
Error
(
std
::
string
strRejectReasonIn
=
""
)
{
if
(
mode
==
MODE_VALID
)
strRejectReason
=
strRejectReasonIn
;
mode
=
MODE_ERROR
;
return
false
;
}
bool
IsValid
()
const
{
return
mode
==
MODE_VALID
;
}
bool
IsInvalid
()
const
{
return
mode
==
MODE_INVALID
;
}
bool
IsError
()
const
{
return
mode
==
MODE_ERROR
;
}
bool
IsInvalid
(
int
&
nDoSOut
)
const
{
if
(
IsInvalid
())
{
nDoSOut
=
nDoS
;
return
true
;
}
return
false
;
}
bool
CorruptionPossible
()
const
{
return
corruptionPossible
;
}
unsigned
char
GetRejectCode
()
const
{
return
chRejectCode
;
}
std
::
string
GetRejectReason
()
const
{
return
strRejectReason
;
}
};
/** RAII wrapper for VerifyDB: Verify consistency of the block and coin databases */
class
CVerifyDB
{
public:
...
...
This diff is collapsed.
Click to expand it.
src/miner.cpp
View file @
f339fff8
...
...
@@ -8,6 +8,7 @@
#include "amount.h"
#include "chainparams.h"
#include "consensus/consensus.h"
#include "consensus/validation.h"
#include "hash.h"
#include "main.h"
#include "net.h"
...
...
This diff is collapsed.
Click to expand it.
src/rpcblockchain.cpp
View file @
f339fff8
...
...
@@ -4,7 +4,9 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "checkpoints.h"
#include "consensus/validation.h"
#include "main.h"
#include "primitives/transaction.h"
#include "rpcserver.h"
#include "sync.h"
#include "util.h"
...
...
This diff is collapsed.
Click to expand it.
src/rpcmining.cpp
View file @
f339fff8
...
...
@@ -6,6 +6,7 @@
#include "amount.h"
#include "chainparams.h"
#include "consensus/consensus.h"
#include "consensus/validation.h"
#include "core_io.h"
#include "init.h"
#include "main.h"
...
...
This diff is collapsed.
Click to expand it.
src/rpcrawtransaction.cpp
View file @
f339fff8
...
...
@@ -4,13 +4,14 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
#include "
primitives/transac
tion.h"
#include "
consensus/valida
tion.h"
#include "core_io.h"
#include "init.h"
#include "keystore.h"
#include "main.h"
#include "merkleblock.h"
#include "net.h"
#include "primitives/transaction.h"
#include "rpcserver.h"
#include "script/script.h"
#include "script/script_error.h"
...
...
This diff is collapsed.
Click to expand it.
src/test/checkblock_tests.cpp
View file @
f339fff8
...
...
@@ -2,16 +2,11 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
// Unit tests for block.CheckBlock()
//
#include "clientversion.h"
#include "consensus/validation.h"
#include "main.h"
#include "utiltime.h"
#include "test/test_bitcoin.h"
#include "utiltime.h"
#include <cstdio>
...
...
This diff is collapsed.
Click to expand it.
src/test/miner_tests.cpp
View file @
f339fff8
...
...
@@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "consensus/validation.h"
#include "main.h"
#include "miner.h"
#include "pubkey.h"
...
...
This diff is collapsed.
Click to expand it.
src/test/sighash_tests.cpp
View file @
f339fff8
...
...
@@ -2,15 +2,16 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "consensus/validation.h"
#include "data/sighash.json.h"
#include "main.h"
#include "random.h"
#include "serialize.h"
#include "script/script.h"
#include "script/interpreter.h"
#include "script/script.h"
#include "serialize.h"
#include "test/test_bitcoin.h"
#include "util.h"
#include "version.h"
#include "test/test_bitcoin.h"
#include <iostream>
...
...
This diff is collapsed.
Click to expand it.
src/test/transaction_tests.cpp
View file @
f339fff8
...
...
@@ -7,12 +7,13 @@
#include "test/test_bitcoin.h"
#include "clientversion.h"
#include "consensus/validation.h"
#include "core_io.h"
#include "key.h"
#include "keystore.h"
#include "main.h"
#include "script/script.h"
#include "script/script_error.h"
#include "core_io.h"
#include <map>
#include <string>
...
...
This diff is collapsed.
Click to expand it.
src/txmempool.cpp
View file @
f339fff8
...
...
@@ -7,6 +7,7 @@
#include "clientversion.h"
#include "consensus/consensus.h"
#include "consensus/validation.h"
#include "main.h"
#include "policy/fees.h"
#include "streams.h"
...
...
This diff is collapsed.
Click to expand it.
src/wallet/wallet.cpp
View file @
f339fff8
...
...
@@ -9,6 +9,7 @@
#include "checkpoints.h"
#include "coincontrol.h"
#include "consensus/consensus.h"
#include "consensus/validation.h"
#include "main.h"
#include "net.h"
#include "script/script.h"
...
...
This diff is collapsed.
Click to expand it.
src/wallet/walletdb.cpp
View file @
f339fff8
...
...
@@ -6,6 +6,7 @@
#include "wallet/walletdb.h"
#include "base58.h"
#include "consensus/validation.h"
#include "main.h"
#include "protocol.h"
#include "serialize.h"
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment