Skip to content

Commit

Permalink
Handle EB0
Browse files Browse the repository at this point in the history
  • Loading branch information
dgenr8 committed May 1, 2017
1 parent d140971 commit af9b878
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/maxblocksize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ uint64_t GetNextMaxBlockSize(const CBlockIndex* pindexLast, const Consensus::Par

static uint32_t FindVote(const std::string& coinbase) {

uint32_t eb_vote = 0;
bool eb_vote = false;
uint32_t ebVoteMB = 0;
std::vector<char> curr;
bool bip100vote = false;
bool started = false;
Expand Down Expand Up @@ -98,8 +99,9 @@ static uint32_t FindVote(const std::string& coinbase) {
// Look for a EB vote. Keep it, but continue to look for a BIP100/B vote.
if (!eb_vote && curr[0] == 'E' && curr[1] == 'B') {
try {
eb_vote = boost::lexical_cast<uint32_t>(std::string(
ebVoteMB = boost::lexical_cast<uint32_t>(std::string(
begin(curr) + 2, end(curr)));
eb_vote = true;
}
catch (const std::exception& e) {
LogPrintf("Invalid coinbase EB-vote: %s\n", e.what());
Expand All @@ -115,7 +117,7 @@ static uint32_t FindVote(const std::string& coinbase) {
else
curr.push_back(s);
}
return eb_vote;
return ebVoteMB;
}

uint64_t GetMaxBlockSizeVote(const CScript &coinbase, int32_t nHeight)
Expand Down
8 changes: 7 additions & 1 deletion src/test/maxblocksize_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,15 @@ BOOST_AUTO_TEST_CASE(get_max_blocksize_vote_no_vote) {

// missing BIP100 prefix
BOOST_CHECK_EQUAL(0, GetMaxBlockSizeVote(CScript() << to_uchar("/B2/"), height));

BOOST_CHECK_EQUAL(0, GetMaxBlockSizeVote(CScript() << to_uchar("/BIP100/B/B8/"), height));

//Explicit zeros and garbage
BOOST_CHECK_EQUAL(0, GetMaxBlockSizeVote(CScript() << to_uchar("/BIP100/B0/BIP100/B2"), height));
BOOST_CHECK_EQUAL(0, GetMaxBlockSizeVote(CScript() << to_uchar("/EB0/EB2/"), height));
BOOST_CHECK_EQUAL(0, GetMaxBlockSizeVote(CScript() << to_uchar("/BIP100/Bgarbage/B2/"), height));
BOOST_CHECK_EQUAL(2000000, GetMaxBlockSizeVote(CScript() << to_uchar("/EBgarbage/EB2/"), height));


// Test that height is not a part of the vote string.
// Encoded height in this test ends with /.
// Should not be interpreted as /BIP100/B8/
Expand Down

0 comments on commit af9b878

Please sign in to comment.