Attempt 2

bcn
Petar Mitchev 2016-04-21 19:14:04 +03:00
parent 73f7d00915
commit e5ac040561
4 changed files with 14 additions and 3 deletions

View File

@ -7,6 +7,7 @@
#define BLOCK_MAJOR_VERSION_1 1
#define BLOCK_MAJOR_VERSION_2 2
#define BLOCK_MAJOR_VERSION_3 3
#define COIN ((uint64_t)100000000) // pow(10, 8)
#define DEFAULT_FEE ((uint64_t)1000000) // pow(10, 6)

View File

@ -456,7 +456,7 @@ namespace cryptonote
BEGIN_SERIALIZE()
VARINT_FIELD(major_version)
if(major_version > BLOCK_MAJOR_VERSION_2) return false;
if(major_version > BLOCK_MAJOR_VERSION_3) return false;
VARINT_FIELD(minor_version)
if (BLOCK_MAJOR_VERSION_1 == major_version)
{

View File

@ -860,7 +860,7 @@ namespace cryptonote
//---------------------------------------------------------------
bool check_proof_of_work_v2(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work)
{
if (BLOCK_MAJOR_VERSION_2 != bl.major_version)
if (BLOCK_MAJOR_VERSION_2 != bl.major_version || BLOCK_MAJOR_VERSION_3 != bl.major_version)
return false;
if (!get_bytecoin_block_longhash(bl, proof_of_work))
@ -900,6 +900,7 @@ namespace cryptonote
{
case BLOCK_MAJOR_VERSION_1: return check_proof_of_work_v1(bl, current_diffic, proof_of_work);
case BLOCK_MAJOR_VERSION_2: return check_proof_of_work_v2(bl, current_diffic, proof_of_work);
case BLOCK_MAJOR_VERSION_3: return check_proof_of_work_v2(bl, current_diffic, proof_of_work);
}
CHECK_AND_ASSERT_MES(false, false, "unknown block major version: " << bl.major_version << "." << bl.minor_version);

View File

@ -96,7 +96,7 @@ Handle<Value> convert_blob(const Arguments& args) {
if (!parse_and_validate_block_from_blob(input, b))
return except("Failed to parse block");
if (b.major_version < BLOCK_MAJOR_VERSION_2) {
if (b.major_version < BLOCK_MAJOR_VERSION_3) {
if (!get_block_hashing_blob(b, output))
return except("Failed to create mining block");
} else {
@ -172,6 +172,15 @@ Handle<Value> construct_block_blob(const Arguments& args) {
if (!mergeBlocks(parent_block, b, std::vector<crypto::hash>()))
return except("Failed to postprocess mining block");
}
if (b.major_version == BLOCK_MAJOR_VERSION_3) {
block parent_block;
b.parent_block.nonce = nonce;
if (!construct_parent_block(b, parent_block))
return except("Failed to construct parent block");
if (!mergeBlocks(parent_block, b, std::vector<crypto::hash>()))
return except("Failed to postprocess mining block");
}
if (!block_to_blob(b, output))
return except("Failed to convert block to blob");