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
defunctec
crown-core
Commits
6e329f8a
Commit
6e329f8a
authored
6 years ago
by
Zhenzhen Zhan
Browse files
Options
Download
Email Patches
Plain Diff
Temporarily fix #261
parent
5ed86b61
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/main.cpp
+12
-73
src/main.cpp
src/main.h
+0
-2
src/main.h
src/primitives/block.h
+4
-10
src/primitives/block.h
src/version.h
+0
-3
src/version.h
with
16 additions
and
88 deletions
+16
-88
src/main.cpp
View file @
6e329f8a
...
...
@@ -168,12 +168,6 @@ namespace {
/** Dirty block file entries. */
set<int> setDirtyFileInfo;
/** Map which holds received headers auxpow **/
std
::
map
<
uint256
,
CAuxPow
>
mapAuxPow
;
/** Indicator to start/stop headers sync **/
bool
g_headerSyncStopped
=
false
;
} // anon namespace
//////////////////////////////////////////////////////////////////////////////
...
...
@@ -3599,9 +3593,6 @@ bool static LoadBlockIndexDB()
return true;
chainActive.SetTip(it->second);
// This function calls after relaunch so download headers again
pindexBestHeader
=
chainActive
.
Tip
();
PruneBlockIndexCandidates();
LogPrintf("LoadBlockIndexDB(): hashBestChain=%s height=%d date=%s progress=%f\n",
...
...
@@ -4193,12 +4184,7 @@ void static ProcessGetData(CNode* pfrom)
if (!ReadBlockFromDisk(block, (*mi).second))
assert(!"cannot load block from disk");
if (inv.type == MSG_BLOCK)
{
// Don't send auxpow information with block
block
.
auxpow
.
reset
();
block
.
readWriteAuxPow
=
false
;
pfrom->PushMessage("block", block);
}
else // MSG_FILTERED_BLOCK)
{
LOCK(pfrom->cs_filter);
...
...
@@ -4967,22 +4953,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
return error(strError.c_str());
}
}
else
{
if
(
header
.
nVersion
.
IsAuxpow
())
{
// If block header is accepted successfully keep auxpow to use for blocks
mapAuxPow
.
insert
(
std
::
pair
<
uint256
,
CAuxPow
>
(
header
.
GetHash
(),
*
(
header
.
auxpow
)));
}
}
}
if (pindexLast)
UpdateBlockAvailability(pfrom->GetId(), pindexLast->GetBlockHash());
// Don't let headers sync to go further more than 50.000 blocks
if
(
pindexBestHeader
->
nHeight
-
chainActive
.
Tip
()
->
nHeight
<
MAX_HEADERS_IN_MEMORY
)
{
if (nCount == MAX_HEADERS_RESULTS && pindexLast && hasNewHeaders) {
// Headers message had its maximum size; the peer may have more headers.
// TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue
...
...
@@ -4990,11 +4965,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
LogPrint("net", "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->id, pfrom->nStartingHeight);
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256());
}
}
else
{
g_headerSyncStopped
=
true
;
}
CheckBlockIndex();
}
...
...
@@ -5002,47 +4972,24 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing
{
CBlock block;
// Auxpow should be received with headers so no need to get it with blocks
if
(
pfrom
->
nVersion
>
AUXPOW_SEND_VERSION
)
{
block
.
readWriteAuxPow
=
false
;
}
vRecv >> block;
bool
processBlock
=
true
;
if
(
block
.
nVersion
.
IsAuxpow
()
&&
pfrom
->
nVersion
>
AUXPOW_SEND_VERSION
)
{
std
::
map
<
uint256
,
CAuxPow
>::
iterator
auxIt
=
mapAuxPow
.
find
(
block
.
GetHash
());
if
(
auxIt
!=
mapAuxPow
.
end
())
{
block
.
auxpow
.
reset
(
new
CAuxPow
(
auxIt
->
second
));
mapAuxPow
.
erase
(
block
.
GetHash
());
}
else
{
LogPrintf
(
"Couldn't find auxpow for block: %s, at height: %d
\n
"
,
block
.
GetHash
().
ToString
(),
chainActive
.
Tip
()
->
nHeight
);
processBlock
=
false
;
}
}
CInv inv(MSG_BLOCK, block.GetHash());
LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
if
(
processBlock
)
{
CInv
inv
(
MSG_BLOCK
,
block
.
GetHash
());
LogPrint
(
"net"
,
"received block %s peer=%d
\n
"
,
inv
.
hash
.
ToString
(),
pfrom
->
id
);
pfrom
->
AddInventoryKnown
(
inv
);
pfrom->AddInventoryKnown(inv);
CValidationState
state
;
ProcessNewBlock
(
state
,
pfrom
,
&
block
);
int
nDoS
;
if
(
state
.
IsInvalid
(
nDoS
))
{
pfrom
->
PushMessage
(
"reject"
,
strCommand
,
state
.
GetRejectCode
(),
state
.
GetRejectReason
().
substr
(
0
,
MAX_REJECT_MESSAGE_LENGTH
),
inv
.
hash
);
if
(
nDoS
>
0
)
{
TRY_LOCK
(
cs_main
,
lockMain
);
if
(
lockMain
)
Misbehaving
(
pfrom
->
GetId
(),
nDoS
);
}
CValidationState state;
ProcessNewBlock(state, pfrom, &block);
int nDoS;
if (state.IsInvalid(nDoS)) {
pfrom->PushMessage("reject", strCommand, state.GetRejectCode(),
state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash);
if (nDoS > 0) {
TRY_LOCK(cs_main, lockMain);
if(lockMain) Misbehaving(pfrom->GetId(), nDoS);
}
}
}
...
...
@@ -5526,14 +5473,6 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
}
}
// Restart headers sync if synced blocks coint is 10% behinde from headers
const
int
restartLimit
=
(
MAX_HEADERS_IN_MEMORY
*
10
)
/
100
;
if
(
g_headerSyncStopped
&&
(
pindexBestHeader
->
nHeight
-
chainActive
.
Tip
()
->
nHeight
<
restartLimit
))
{
g_headerSyncStopped
=
false
;
pto
->
PushMessage
(
"getheaders"
,
chainActive
.
GetLocator
(
pindexBestHeader
),
uint256
());
}
// Resend wallet transactions that haven't gotten in a block yet
// Except during reindex, importing and IBD, when old wallet
// transactions become unconfirmed and spams other nodes.
...
...
This diff is collapsed.
Click to expand it.
src/main.h
View file @
6e329f8a
...
...
@@ -100,8 +100,6 @@ static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
static
const
unsigned
int
DATABASE_FLUSH_INTERVAL
=
24
*
60
*
60
;
/** Maximum length of reject messages. */
static
const
unsigned
int
MAX_REJECT_MESSAGE_LENGTH
=
111
;
/** Maximum number headers in memory */
static
const
int
MAX_HEADERS_IN_MEMORY
=
50000
;
/** "reject" message codes */
static
const
unsigned
char
REJECT_MALFORMED
=
0x01
;
...
...
This diff is collapsed.
Click to expand it.
src/primitives/block.h
View file @
6e329f8a
...
...
@@ -13,7 +13,6 @@
#include "uint256.h"
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
/** The maximum allowed size for a serialized block, in bytes (network rule) */
static
const
unsigned
int
MAX_BLOCK_SIZE
=
1000000
;
...
...
@@ -31,7 +30,6 @@ public:
// auxpow (if this is a merge-minded block)
boost
::
shared_ptr
<
CAuxPow
>
auxpow
;
bool
readWriteAuxPow
;
CBlockHeader
()
{
...
...
@@ -46,13 +44,10 @@ public:
nVersion
=
this
->
nVersion
.
GetBaseVersion
();
if
(
this
->
nVersion
.
IsAuxpow
())
{
if
(
readWriteAuxPow
)
{
if
(
ser_action
.
ForRead
())
auxpow
=
boost
::
make_shared
<
CAuxPow
>
();
assert
(
auxpow
);
READWRITE
(
*
auxpow
);
}
if
(
ser_action
.
ForRead
())
auxpow
.
reset
(
new
CAuxPow
());
assert
(
auxpow
);
READWRITE
(
*
auxpow
);
}
else
if
(
ser_action
.
ForRead
())
auxpow
.
reset
();
}
...
...
@@ -66,7 +61,6 @@ public:
nTime
=
0
;
nBits
=
0
;
nNonce
=
0
;
readWriteAuxPow
=
true
;
}
bool
IsNull
()
const
...
...
This diff is collapsed.
Click to expand it.
src/version.h
View file @
6e329f8a
...
...
@@ -53,7 +53,4 @@ static const int BIP0031_VERSION = 60000;
//! "mempool" command, enhanced "getdata" behavior starts with this version
static
const
int
MEMPOOL_GD_VERSION
=
60002
;
//! Nodes above this version won't send AuxPow information with blocks
static
const
int
AUXPOW_SEND_VERSION
=
70053
;
#endif // BITCOIN_VERSION_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
Menu
Projects
Groups
Snippets
Help