Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Josh Wilcox
crown-core
Commits
a824d45a
Commit
a824d45a
authored
12 years ago
by
Jeff Garzik
Committed by
Jeff Garzik
12 years ago
Browse files
Options
Download
Email Patches
Plain Diff
SigOp and orphan-tx constants and counts are always unsigned.
Fixes several sign-comparison warnings.
parent
db7d3d8b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/main.cpp
+11
-11
src/main.cpp
src/main.h
+4
-4
src/main.h
src/script.cpp
+5
-5
src/script.cpp
src/script.h
+2
-2
src/script.h
src/test/DoS_tests.cpp
+1
-1
src/test/DoS_tests.cpp
with
23 additions
and
23 deletions
+23
-23
src/main.cpp
View file @
a824d45a
...
...
@@ -195,9 +195,9 @@ void static EraseOrphanTx(uint256 hash)
mapOrphanTransactions
.
erase
(
hash
);
}
int
LimitOrphanTxSize
(
int
nMaxOrphans
)
unsigned
int
LimitOrphanTxSize
(
unsigned
int
nMaxOrphans
)
{
int
nEvicted
=
0
;
unsigned
int
nEvicted
=
0
;
while
(
mapOrphanTransactions
.
size
()
>
nMaxOrphans
)
{
// Evict a random orphan:
...
...
@@ -328,10 +328,10 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const
return
true
;
}
int
unsigned
int
CTransaction
::
GetLegacySigOpCount
()
const
{
int
nSigOps
=
0
;
unsigned
int
nSigOps
=
0
;
BOOST_FOREACH
(
const
CTxIn
&
txin
,
vin
)
{
nSigOps
+=
txin
.
scriptSig
.
GetSigOpCount
(
false
);
...
...
@@ -1079,12 +1079,12 @@ int64 CTransaction::GetValueIn(const MapPrevTx& inputs) const
}
int
CTransaction
::
GetP2SHSigOpCount
(
const
MapPrevTx
&
inputs
)
const
unsigned
int
CTransaction
::
GetP2SHSigOpCount
(
const
MapPrevTx
&
inputs
)
const
{
if
(
IsCoinBase
())
return
0
;
int
nSigOps
=
0
;
unsigned
int
nSigOps
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
vin
.
size
();
i
++
)
{
const
CTxOut
&
prevout
=
GetOutputFor
(
vin
[
i
],
inputs
);
...
...
@@ -1284,7 +1284,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
map
<
uint256
,
CTxIndex
>
mapQueuedChanges
;
int64
nFees
=
0
;
int
nSigOps
=
0
;
unsigned
int
nSigOps
=
0
;
BOOST_FOREACH
(
CTransaction
&
tx
,
vtx
)
{
nSigOps
+=
tx
.
GetLegacySigOpCount
();
...
...
@@ -1645,7 +1645,7 @@ bool CBlock::CheckBlock() const
if
(
!
tx
.
CheckTransaction
())
return
DoS
(
tx
.
nDoS
,
error
(
"CheckBlock() : CheckTransaction failed"
));
int
nSigOps
=
0
;
unsigned
int
nSigOps
=
0
;
BOOST_FOREACH
(
const
CTransaction
&
tx
,
vtx
)
{
nSigOps
+=
tx
.
GetLegacySigOpCount
();
...
...
@@ -2583,9 +2583,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
AddOrphanTx
(
vMsg
);
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
int
nEvicted
=
LimitOrphanTxSize
(
MAX_ORPHAN_TRANSACTIONS
);
unsigned
int
nEvicted
=
LimitOrphanTxSize
(
MAX_ORPHAN_TRANSACTIONS
);
if
(
nEvicted
>
0
)
printf
(
"mapOrphan overflow, removed %
d
tx
\n
"
,
nEvicted
);
printf
(
"mapOrphan overflow, removed %
u
tx
\n
"
,
nEvicted
);
}
if
(
tx
.
nDoS
)
pfrom
->
Misbehaving
(
tx
.
nDoS
);
}
...
...
@@ -3209,7 +3209,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
continue
;
// Legacy limits on sigOps:
int
nTxSigOps
=
tx
.
GetLegacySigOpCount
();
unsigned
int
nTxSigOps
=
tx
.
GetLegacySigOpCount
();
if
(
nBlockSigOps
+
nTxSigOps
>=
MAX_BLOCK_SIGOPS
)
continue
;
...
...
This diff is collapsed.
Click to expand it.
src/main.h
View file @
a824d45a
...
...
@@ -28,8 +28,8 @@ class CNode;
static
const
unsigned
int
MAX_BLOCK_SIZE
=
1000000
;
static
const
unsigned
int
MAX_BLOCK_SIZE_GEN
=
MAX_BLOCK_SIZE
/
2
;
static
const
int
MAX_BLOCK_SIGOPS
=
MAX_BLOCK_SIZE
/
50
;
static
const
int
MAX_ORPHAN_TRANSACTIONS
=
MAX_BLOCK_SIZE
/
100
;
static
const
unsigned
int
MAX_BLOCK_SIGOPS
=
MAX_BLOCK_SIZE
/
50
;
static
const
unsigned
int
MAX_ORPHAN_TRANSACTIONS
=
MAX_BLOCK_SIZE
/
100
;
static
const
int64
MIN_TX_FEE
=
50000
;
static
const
int64
MIN_RELAY_TX_FEE
=
10000
;
static
const
int64
MAX_MONEY
=
21000000
*
COIN
;
...
...
@@ -495,7 +495,7 @@ public:
@return number of sigops this transaction's outputs will produce when spent
@see CTransaction::FetchInputs
*/
int
GetLegacySigOpCount
()
const
;
unsigned
int
GetLegacySigOpCount
()
const
;
/** Count ECDSA signature operations in pay-to-script-hash inputs.
...
...
@@ -503,7 +503,7 @@ public:
@return maximum number of sigops required to validate this transaction's inputs
@see CTransaction::FetchInputs
*/
int
GetP2SHSigOpCount
(
const
MapPrevTx
&
mapInputs
)
const
;
unsigned
int
GetP2SHSigOpCount
(
const
MapPrevTx
&
mapInputs
)
const
;
/** Amount of bitcoins spent by this transaction.
@return sum of all outputs (note: does not include fees)
...
...
This diff is collapsed.
Click to expand it.
src/script.cpp
View file @
a824d45a
...
...
@@ -1360,9 +1360,9 @@ bool IsStandard(const CScript& scriptPubKey)
}
int
HaveKeys
(
const
vector
<
valtype
>&
pubkeys
,
const
CKeyStore
&
keystore
)
unsigned
int
HaveKeys
(
const
vector
<
valtype
>&
pubkeys
,
const
CKeyStore
&
keystore
)
{
int
nResult
=
0
;
unsigned
int
nResult
=
0
;
BOOST_FOREACH
(
const
valtype
&
pubkey
,
pubkeys
)
{
CBitcoinAddress
address
;
...
...
@@ -1566,9 +1566,9 @@ bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsig
return
true
;
}
int
CScript
::
GetSigOpCount
(
bool
fAccurate
)
const
unsigned
int
CScript
::
GetSigOpCount
(
bool
fAccurate
)
const
{
int
n
=
0
;
unsigned
int
n
=
0
;
const_iterator
pc
=
begin
();
opcodetype
lastOpcode
=
OP_INVALIDOPCODE
;
while
(
pc
<
end
())
...
...
@@ -1590,7 +1590,7 @@ int CScript::GetSigOpCount(bool fAccurate) const
return
n
;
}
int
CScript
::
GetSigOpCount
(
const
CScript
&
scriptSig
)
const
unsigned
int
CScript
::
GetSigOpCount
(
const
CScript
&
scriptSig
)
const
{
if
(
!
IsPayToScriptHash
())
return
GetSigOpCount
(
true
);
...
...
This diff is collapsed.
Click to expand it.
src/script.h
View file @
a824d45a
...
...
@@ -491,11 +491,11 @@ public:
// CHECKMULTISIGs serialized in scriptSigs are
// counted more accurately, assuming they are of the form
// ... OP_N CHECKMULTISIG ...
int
GetSigOpCount
(
bool
fAccurate
)
const
;
unsigned
int
GetSigOpCount
(
bool
fAccurate
)
const
;
// Accurately count sigOps, including sigOps in
// pay-to-script-hash transactions:
int
GetSigOpCount
(
const
CScript
&
scriptSig
)
const
;
unsigned
int
GetSigOpCount
(
const
CScript
&
scriptSig
)
const
;
bool
IsPayToScriptHash
()
const
;
...
...
This diff is collapsed.
Click to expand it.
src/test/DoS_tests.cpp
View file @
a824d45a
...
...
@@ -14,7 +14,7 @@
// Tests this internal-to-main.cpp method:
extern
void
AddOrphanTx
(
const
CDataStream
&
vMsg
);
extern
int
LimitOrphanTxSize
(
int
nMaxOrphans
);
extern
unsigned
int
LimitOrphanTxSize
(
unsigned
int
nMaxOrphans
);
extern
std
::
map
<
uint256
,
CDataStream
*>
mapOrphanTransactions
;
extern
std
::
multimap
<
uint256
,
CDataStream
*>
mapOrphanTransactionsByPrev
;
...
...
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
Menu
Projects
Groups
Snippets
Help