Aeon support
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cryptoforknote-util",
|
"name": "cryptoforknote-util",
|
||||||
"version": "5.0.0",
|
"version": "6.0.0",
|
||||||
"main": "cryptoforknote-util",
|
"main": "cryptoforknote-util",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "LucasJones",
|
"name": "LucasJones",
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ enum BLOB_TYPE {
|
|||||||
BLOB_TYPE_CRYPTONOTE_RYO = 4, // Ryo
|
BLOB_TYPE_CRYPTONOTE_RYO = 4, // Ryo
|
||||||
BLOB_TYPE_CRYPTONOTE_LOKI = 5, // Loki
|
BLOB_TYPE_CRYPTONOTE_LOKI = 5, // Loki
|
||||||
BLOB_TYPE_CRYPTONOTE3 = 6, // Masari
|
BLOB_TYPE_CRYPTONOTE3 = 6, // Masari
|
||||||
|
BLOB_TYPE_AEON = 7, // Aeon
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -429,14 +429,23 @@ namespace cryptonote
|
|||||||
uint8_t minor_version;
|
uint8_t minor_version;
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
crypto::hash prev_id;
|
crypto::hash prev_id;
|
||||||
uint32_t nonce;
|
uint64_t nonce;
|
||||||
|
|
||||||
BEGIN_SERIALIZE()
|
BEGIN_SERIALIZE()
|
||||||
VARINT_FIELD(major_version)
|
VARINT_FIELD(major_version)
|
||||||
VARINT_FIELD(minor_version)
|
VARINT_FIELD(minor_version)
|
||||||
if (blob_type != BLOB_TYPE_FORKNOTE2) VARINT_FIELD(timestamp)
|
if (blob_type != BLOB_TYPE_FORKNOTE2) VARINT_FIELD(timestamp)
|
||||||
FIELD(prev_id)
|
FIELD(prev_id)
|
||||||
if (blob_type != BLOB_TYPE_FORKNOTE2) FIELD(nonce)
|
if (blob_type != BLOB_TYPE_FORKNOTE2) {
|
||||||
|
if (blob_type == BLOB_TYPE_AEON) {
|
||||||
|
FIELD(nonce)
|
||||||
|
} else {
|
||||||
|
uint32_t nonce32;
|
||||||
|
if (typename Archive<W>::is_saving()) nonce32 = (uint32_t)nonce;
|
||||||
|
FIELD_N("nonce", nonce32);
|
||||||
|
if (!typename Archive<W>::is_saving()) nonce = nonce32;
|
||||||
|
}
|
||||||
|
}
|
||||||
END_SERIALIZE()
|
END_SERIALIZE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
11
src/main.cc
11
src/main.cc
@@ -191,11 +191,6 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c
|
|||||||
Local<Object> nonce_buf = info[1]->ToObject();
|
Local<Object> nonce_buf = info[1]->ToObject();
|
||||||
|
|
||||||
if (!Buffer::HasInstance(block_template_buf) || !Buffer::HasInstance(nonce_buf)) return THROW_ERROR_EXCEPTION("Both arguments should be buffer objects.");
|
if (!Buffer::HasInstance(block_template_buf) || !Buffer::HasInstance(nonce_buf)) return THROW_ERROR_EXCEPTION("Both arguments should be buffer objects.");
|
||||||
if (Buffer::Length(nonce_buf) != 4) return THROW_ERROR_EXCEPTION("Nonce buffer has invalid size.");
|
|
||||||
|
|
||||||
uint32_t nonce = *reinterpret_cast<uint32_t*>(Buffer::Data(nonce_buf));
|
|
||||||
blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf));
|
|
||||||
blobdata output = "";
|
|
||||||
|
|
||||||
enum BLOB_TYPE blob_type = BLOB_TYPE_CRYPTONOTE;
|
enum BLOB_TYPE blob_type = BLOB_TYPE_CRYPTONOTE;
|
||||||
if (info.Length() >= 3) {
|
if (info.Length() >= 3) {
|
||||||
@@ -203,6 +198,12 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c
|
|||||||
blob_type = static_cast<enum BLOB_TYPE>(Nan::To<int>(info[2]).FromMaybe(0));
|
blob_type = static_cast<enum BLOB_TYPE>(Nan::To<int>(info[2]).FromMaybe(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Buffer::Length(nonce_buf) != (blob_type == BLOB_TYPE_AEON ? 8 : 4)) return THROW_ERROR_EXCEPTION("Nonce buffer has invalid size.");
|
||||||
|
|
||||||
|
uint64_t nonce = blob_type == BLOB_TYPE_AEON ? *reinterpret_cast<uint64_t*>(Buffer::Data(nonce_buf)) : *reinterpret_cast<uint32_t*>(Buffer::Data(nonce_buf));
|
||||||
|
blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf));
|
||||||
|
blobdata output = "";
|
||||||
|
|
||||||
block b = AUTO_VAL_INIT(b);
|
block b = AUTO_VAL_INIT(b);
|
||||||
b.set_blob_type(blob_type);
|
b.set_blob_type(blob_type);
|
||||||
if (!parse_and_validate_block_from_blob(block_template_blob, b)) return THROW_ERROR_EXCEPTION("Failed to parse block");
|
if (!parse_and_validate_block_from_blob(block_template_blob, b)) return THROW_ERROR_EXCEPTION("Failed to parse block");
|
||||||
|
|||||||
Reference in New Issue
Block a user