Better separated bcn stuff
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
|
||||
#define CURRENT_TRANSACTION_VERSION 1
|
||||
#define MAX_TRANSACTION_VERSION 2
|
||||
#define CURRENT_BLOCK_MAJOR_VERSION 1
|
||||
#define CURRENT_BLOCK_MINOR_VERSION 0
|
||||
|
||||
|
||||
@@ -174,10 +174,7 @@ namespace cryptonote
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(version)
|
||||
if(CURRENT_TRANSACTION_VERSION < version) {
|
||||
puts("!!! Too high tx version for serialization");
|
||||
return false;
|
||||
}
|
||||
if(MAX_TRANSACTION_VERSION < version) return false;
|
||||
VARINT_FIELD(unlock_time)
|
||||
FIELD(vin)
|
||||
FIELD(vout)
|
||||
@@ -486,9 +483,7 @@ namespace cryptonote
|
||||
VARINT_FIELD(minor_version)
|
||||
if (BLOCK_MAJOR_VERSION_1 == major_version)
|
||||
{
|
||||
puts("[6");
|
||||
VARINT_FIELD(timestamp)
|
||||
puts("]6");
|
||||
}
|
||||
FIELD(prev_id)
|
||||
if (BLOCK_MAJOR_VERSION_1 == major_version)
|
||||
@@ -509,10 +504,8 @@ namespace cryptonote
|
||||
FIELDS(*static_cast<block_header *>(this))
|
||||
if (BLOCK_MAJOR_VERSION_2 == major_version || BLOCK_MAJOR_VERSION_3 == major_version)
|
||||
{
|
||||
puts("[7");
|
||||
auto sbb = make_serializable_bytecoin_block(*this, false, false);
|
||||
FIELD_N("parent_block", sbb);
|
||||
puts("]7");
|
||||
}
|
||||
FIELD(miner_tx)
|
||||
FIELD(tx_hashes)
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace cryptonote
|
||||
|
||||
CHECK_AND_ASSERT_MES(summary_amounts == block_reward, false, "Failed to construct miner tx, summary_amounts = " << summary_amounts << " not equal block_reward = " << block_reward);
|
||||
|
||||
puts("[*] Using CURRENT_TRANSACTION_VERSION in construct_miner_tx");
|
||||
tx.version = CURRENT_TRANSACTION_VERSION;
|
||||
//lock
|
||||
tx.unlock_time = height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
|
||||
@@ -322,6 +323,7 @@ namespace cryptonote
|
||||
tx.vout.clear();
|
||||
tx.signatures.clear();
|
||||
|
||||
puts("[*] Using CURRENT_TRANSACTION_VERSION in construct_tx");
|
||||
tx.version = CURRENT_TRANSACTION_VERSION;
|
||||
tx.unlock_time = unlock_time;
|
||||
|
||||
@@ -705,16 +707,14 @@ namespace cryptonote
|
||||
if (!get_block_hashing_blob(b, blob))
|
||||
return false;
|
||||
|
||||
if (BLOCK_MAJOR_VERSION_2 <= b.major_version)
|
||||
if (BLOCK_MAJOR_VERSION_2 == b.major_version || BLOCK_MAJOR_VERSION_3 == b.major_version)
|
||||
{
|
||||
puts("[5");
|
||||
blobdata parent_blob;
|
||||
auto sbb = make_serializable_bytecoin_block(b, true, false);
|
||||
if (!t_serializable_object_to_blob(sbb, parent_blob))
|
||||
return false;
|
||||
|
||||
blob.append(parent_blob);
|
||||
puts("]5");
|
||||
}
|
||||
|
||||
return get_object_hash(blob, res);
|
||||
@@ -755,10 +755,6 @@ namespace cryptonote
|
||||
string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl);
|
||||
bool r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
|
||||
puts("[4");
|
||||
bl.major_version = CURRENT_BLOCK_MAJOR_VERSION;
|
||||
bl.minor_version = CURRENT_BLOCK_MINOR_VERSION;
|
||||
puts("]4");
|
||||
bl.timestamp = 0;
|
||||
bl.nonce = 10000;
|
||||
miner::find_nonce_for_given_block(bl, 1, 0);
|
||||
@@ -910,10 +906,8 @@ namespace cryptonote
|
||||
//---------------------------------------------------------------
|
||||
bool check_proof_of_work_v1(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work)
|
||||
{
|
||||
puts("[3");
|
||||
if (BLOCK_MAJOR_VERSION_1 != bl.major_version)
|
||||
return false;
|
||||
puts("]3");
|
||||
|
||||
proof_of_work = get_block_longhash(bl, 0);
|
||||
return check_hash(proof_of_work, current_diffic);
|
||||
@@ -921,11 +915,9 @@ namespace cryptonote
|
||||
//---------------------------------------------------------------
|
||||
bool check_proof_of_work_v2(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work)
|
||||
{
|
||||
puts("[2");
|
||||
if (BLOCK_MAJOR_VERSION_2 != bl.major_version &&
|
||||
BLOCK_MAJOR_VERSION_3 != bl.major_version)
|
||||
return false;
|
||||
puts("]2");
|
||||
|
||||
if (!get_bytecoin_block_longhash(bl, proof_of_work))
|
||||
return false;
|
||||
@@ -960,14 +952,12 @@ namespace cryptonote
|
||||
//---------------------------------------------------------------
|
||||
bool check_proof_of_work(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work)
|
||||
{
|
||||
puts("[1");
|
||||
switch (bl.major_version)
|
||||
{
|
||||
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);
|
||||
}
|
||||
puts("]1");
|
||||
|
||||
CHECK_AND_ASSERT_MES(false, false, "unknown block major version: " << bl.major_version << "." << bl.minor_version);
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ NAN_METHOD(convert_blob) {
|
||||
block b = AUTO_VAL_INIT(b);
|
||||
if (!parse_and_validate_block_from_blob(input, b)) return THROW_ERROR_EXCEPTION("Failed to parse block");
|
||||
|
||||
if (b.major_version < BLOCK_MAJOR_VERSION_2) {
|
||||
if (!get_block_hashing_blob(b, output)) return THROW_ERROR_EXCEPTION("Failed to create mining block");
|
||||
} else {
|
||||
if (b.major_version == BLOCK_MAJOR_VERSION_2 || b.major_version == BLOCK_MAJOR_VERSION_3) {
|
||||
block parent_block;
|
||||
if (!construct_parent_block(b, parent_block)) return THROW_ERROR_EXCEPTION("Failed to construct parent block");
|
||||
if (!get_block_hashing_blob(parent_block, output)) return THROW_ERROR_EXCEPTION("Failed to create mining block");
|
||||
} else {
|
||||
if (!get_block_hashing_blob(b, output)) return THROW_ERROR_EXCEPTION("Failed to create mining block");
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked();
|
||||
|
||||
Reference in New Issue
Block a user