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
Tom Bradshaw
crown-core
Commits
63ead324
Commit
63ead324
authored
6 years ago
by
Tom Bradshaw
Browse files
Options
Download
Email Patches
Plain Diff
Make MasternodePing serialization compatible with old and new protocols.
parent
7cdb6b49
Pipeline
#942
failed with stage
in 1 minute and 13 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
src/main.cpp
+18
-13
src/main.cpp
src/masternode-budget.cpp
+1
-0
src/masternode-budget.cpp
src/masternode.cpp
+1
-1
src/masternode.cpp
src/masternode.h
+2
-2
src/masternode.h
src/masternodeman.cpp
+12
-2
src/masternodeman.cpp
src/version.h
+2
-2
src/version.h
with
36 additions
and
20 deletions
+36
-20
src/main.cpp
View file @
63ead324
...
...
@@ -2172,7 +2172,7 @@ bool CheckBlockProofPointer(const CBlockIndex* pindex, const CBlock& block, CPub
return
error
(
"%s: Stake pointer from height %d is too recent"
,
__func__
,
pindexFrom
->
nHeight
);
//No stakepointers from budgetblocks
if
(
budget
.
IsBudgetPaymentBlock
(
pindexFrom
->
nHeight
))
if
(
GetAdjustedTime
()
-
block
.
GetBlockTime
()
<
24
*
60
*
60
&&
budget
.
IsBudgetPaymentBlock
(
pindexFrom
->
nHeight
))
return
error
(
"%s: Stake pointers cannot be from budget blocks"
,
__func__
);
//Ensure that this stake pointer is not already used by another block in the chain
...
...
@@ -4609,30 +4609,36 @@ void static ProcessGetData(CNode* pfrom)
if
(
!
pushed
&&
inv
.
type
==
MSG_MASTERNODE_ANNOUNCE
)
{
if
(
mnodeman
.
mapSeenMasternodeBroadcast
.
count
(
inv
.
hash
))
{
int
nVersionSend
=
PROTOCOL_VERSION
;
auto
mnb
=
mnodeman
.
mapSeenMasternodeBroadcast
[
inv
.
hash
];
std
::
string
strCommand
=
"mnb_new"
;
if
(
pfrom
->
nVersion
<
MIN_MNW_PING_VERSION
)
{
//Make sure this serializes to a format that is readable by the peer we are sending to
nVersionSend
=
MIN_MNW_PING_VERSION
-
1
;
mnb
.
lastPing
.
nVersion
=
1
;
}
CDataStream
ss
(
SER_NETWORK
,
nVersionSend
);
if
(
mnb
.
lastPing
.
nVersion
==
1
)
strCommand
=
"mnb"
;
CDataStream
ss
(
SER_NETWORK
,
PROTOCOL_VERSION
);
ss
.
reserve
(
1000
);
ss
<<
mn
odeman
.
mapSeenMasternodeBroadcast
[
inv
.
hash
]
;
pfrom
->
PushMessage
(
"mnb"
,
ss
);
ss
<<
mn
b
;
pfrom
->
PushMessage
(
strCommand
.
c_str
()
,
ss
);
pushed
=
true
;
}
}
if
(
!
pushed
&&
inv
.
type
==
MSG_MASTERNODE_PING
)
{
if
(
mnodeman
.
mapSeenMasternodePing
.
count
(
inv
.
hash
)){
int
nVersionSend
=
PROTOCOL_VERSION
;
auto
mnp
=
mnodeman
.
mapSeenMasternodePing
[
inv
.
hash
];
std
::
string
strCommand
=
"mnp_new"
;
if
(
pfrom
->
nVersion
<
MIN_MNW_PING_VERSION
)
{
//Make sure this serializes to a format that is readable by the peer we are sending to
nVersion
Send
=
MIN_MNW_PING_VERSION
-
1
;
mnp
.
nVersion
=
1
;
}
CDataStream
ss
(
SER_NETWORK
,
nVersionSend
);
if
(
mnp
.
nVersion
==
1
)
strCommand
=
"mnp"
;
CDataStream
ss
(
SER_NETWORK
,
PROTOCOL_VERSION
);
ss
.
reserve
(
1000
);
ss
<<
mn
odeman
.
mapSeenMasternodePing
[
inv
.
hash
]
;
pfrom
->
PushMessage
(
"mnp"
,
ss
);
ss
<<
mn
p
;
pfrom
->
PushMessage
(
strCommand
.
c_str
()
,
ss
);
pushed
=
true
;
}
}
...
...
@@ -4718,8 +4724,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
CAddress
addrFrom
;
uint64_t
nNonce
=
1
;
vRecv
>>
pfrom
->
nVersion
>>
pfrom
->
nServices
>>
nTime
>>
addrMe
;
vRecv
.
nVersion
=
pfrom
->
nVersion
;
if
(
pfrom
->
nVersion
!=
PROTOCOL_VERSION
)
if
(
pfrom
->
nVersion
<
MinPeerProtoVersion
())
{
// disconnect from peers older than this proto version
LogPrintf
(
"peer=%d using obsolete version %i; disconnecting
\n
"
,
pfrom
->
id
,
pfrom
->
nVersion
);
...
...
This diff is collapsed.
Click to expand it.
src/masternode-budget.cpp
View file @
63ead324
...
...
@@ -1237,6 +1237,7 @@ bool CBudgetManager::SubmitProposalVote(const CBudgetVote& vote, std::string& st
mapSeenMasternodeBudgetVotes
.
insert
(
make_pair
(
vote
.
GetHash
(),
vote
));
return
true
;
}
return
false
;
}
bool
CBudgetManager
::
CanSubmitVotes
(
int
blockStart
,
int
blockEnd
)
...
...
This diff is collapsed.
Click to expand it.
src/masternode.cpp
View file @
63ead324
...
...
@@ -911,7 +911,7 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireEnabled, bool fChec
if
(
this
->
nVersion
>
1
)
{
for
(
const
uint256
&
hashBlock
:
vPrevBlockHash
)
{
LogPrint
f
(
"
%s:*************8********** a
dding witness for block %s
\n
"
,
__func__
,
hashBlock
.
GetHex
());
LogPrint
(
"
masternode"
,
"%s: A
dding witness for block
%s from mn
%s
\n
"
,
__func__
,
hashBlock
.
GetHex
()
,
vin
.
ToString
()
);
g_proofTracker
->
AddWitness
(
BlockWitness
(
pmn
->
vin
,
hashBlock
));
}
}
...
...
This diff is collapsed.
Click to expand it.
src/masternode.h
View file @
63ead324
...
...
@@ -64,8 +64,8 @@ public:
READWRITE
(
sigTime
);
READWRITE
(
vchSig
);
//New versioning
signalled comes through protocol version passed to datastream
if
(
nVersion
>=
MIN_MNW_PING_VERSION
)
{
//New versioning
is set externally before serialization
if
(
this
->
nVersion
>=
2
)
{
READWRITE
(
this
->
nVersion
);
READWRITE
(
vPrevBlockHash
);
READWRITE
(
vchSigPrevBlocks
);
...
...
This diff is collapsed.
Click to expand it.
src/masternodeman.cpp
View file @
63ead324
...
...
@@ -537,8 +537,14 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
LOCK
(
cs_process_message
);
if
(
strCommand
==
"mnb"
)
{
//Masternode Broadcast
if
(
strCommand
==
"mnb"
||
strCommand
==
"mnb_new"
)
{
//Masternode Broadcast
CMasternodeBroadcast
mnb
;
if
(
strCommand
==
"mnb"
)
{
//Set to old version for old serialization
mnb
.
lastPing
.
nVersion
=
1
;
}
else
{
mnb
.
lastPing
.
nVersion
=
2
;
}
vRecv
>>
mnb
;
int
nDoS
=
0
;
...
...
@@ -550,8 +556,12 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
}
}
else
if
(
strCommand
==
"mnp"
)
{
//Masternode Ping
else
if
(
strCommand
==
"mnp"
||
strCommand
==
"mnp_new"
)
{
//Masternode Ping
CMasternodePing
mnp
;
if
(
strCommand
==
"mnp"
)
{
//Set to old version for old serialization
mnp
.
nVersion
=
1
;
}
vRecv
>>
mnp
;
LogPrint
(
"masternode"
,
"mnp - Masternode ping, vin: %s
\n
"
,
mnp
.
vin
.
ToString
());
...
...
This diff is collapsed.
Click to expand it.
src/version.h
View file @
63ead324
...
...
@@ -9,7 +9,7 @@
/**
* network protocol versioning
*/
static
const
int
PROTOCOL_VERSION
=
7105
8
;
static
const
int
PROTOCOL_VERSION
=
7105
9
;
static
const
int
PROTOCOL_POS_START
=
71057
;
//! initial proto version, to be increased after version/verack negotiation
...
...
@@ -29,7 +29,7 @@ static const int MIN_BUDGET_PEER_PROTO_VERSION = PROTOCOL_POS_START;
static
const
int
MIN_MNW_PEER_PROTO_VERSION
=
PROTOCOL_POS_START
;
//! minimum version to get version 2 masternode ping messages
static
const
int
MIN_MNW_PING_VERSION
=
7105
8
;
static
const
int
MIN_MNW_PING_VERSION
=
7105
9
;
//! minimum peer version that can receive masternode payments
// V1 - Last protocol version before update
...
...
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