Skip to content

Commit e5ac040

Browse files
committed
Attempt 2
1 parent 73f7d00 commit e5ac040

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/cryptonote_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#define BLOCK_MAJOR_VERSION_1 1
99
#define BLOCK_MAJOR_VERSION_2 2
10+
#define BLOCK_MAJOR_VERSION_3 3
1011

1112
#define COIN ((uint64_t)100000000) // pow(10, 8)
1213
#define DEFAULT_FEE ((uint64_t)1000000) // pow(10, 6)

src/cryptonote_core/cryptonote_basic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ namespace cryptonote
456456

457457
BEGIN_SERIALIZE()
458458
VARINT_FIELD(major_version)
459-
if(major_version > BLOCK_MAJOR_VERSION_2) return false;
459+
if(major_version > BLOCK_MAJOR_VERSION_3) return false;
460460
VARINT_FIELD(minor_version)
461461
if (BLOCK_MAJOR_VERSION_1 == major_version)
462462
{

src/cryptonote_core/cryptonote_format_utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ namespace cryptonote
860860
//---------------------------------------------------------------
861861
bool check_proof_of_work_v2(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work)
862862
{
863-
if (BLOCK_MAJOR_VERSION_2 != bl.major_version)
863+
if (BLOCK_MAJOR_VERSION_2 != bl.major_version || BLOCK_MAJOR_VERSION_3 != bl.major_version)
864864
return false;
865865

866866
if (!get_bytecoin_block_longhash(bl, proof_of_work))
@@ -900,6 +900,7 @@ namespace cryptonote
900900
{
901901
case BLOCK_MAJOR_VERSION_1: return check_proof_of_work_v1(bl, current_diffic, proof_of_work);
902902
case BLOCK_MAJOR_VERSION_2: return check_proof_of_work_v2(bl, current_diffic, proof_of_work);
903+
case BLOCK_MAJOR_VERSION_3: return check_proof_of_work_v2(bl, current_diffic, proof_of_work);
903904
}
904905

905906
CHECK_AND_ASSERT_MES(false, false, "unknown block major version: " << bl.major_version << "." << bl.minor_version);

src/main.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Handle<Value> convert_blob(const Arguments& args) {
9696
if (!parse_and_validate_block_from_blob(input, b))
9797
return except("Failed to parse block");
9898

99-
if (b.major_version < BLOCK_MAJOR_VERSION_2) {
99+
if (b.major_version < BLOCK_MAJOR_VERSION_3) {
100100
if (!get_block_hashing_blob(b, output))
101101
return except("Failed to create mining block");
102102
} else {
@@ -172,6 +172,15 @@ Handle<Value> construct_block_blob(const Arguments& args) {
172172
if (!mergeBlocks(parent_block, b, std::vector<crypto::hash>()))
173173
return except("Failed to postprocess mining block");
174174
}
175+
if (b.major_version == BLOCK_MAJOR_VERSION_3) {
176+
block parent_block;
177+
b.parent_block.nonce = nonce;
178+
if (!construct_parent_block(b, parent_block))
179+
return except("Failed to construct parent block");
180+
181+
if (!mergeBlocks(parent_block, b, std::vector<crypto::hash>()))
182+
return except("Failed to postprocess mining block");
183+
}
175184

176185
if (!block_to_blob(b, output))
177186
return except("Failed to convert block to blob");

0 commit comments

Comments
 (0)