From f3cc70cc0171e861e31028a9e62cd799516cfea8 Mon Sep 17 00:00:00 2001 From: xmvdev Date: Sun, 5 Jan 2020 04:00:11 +0000 Subject: [PATCH] node v12 build fix --- src/main.cc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main.cc b/src/main.cc index b430e95..0cd17f9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -130,7 +130,8 @@ static bool construct_parent_block(const cryptonote::block& b, cryptonote::block NAN_METHOD(convert_blob) { // (parentBlockBuffer, cnBlobType) if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = info[0]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); blobdata input = std::string(Buffer::Data(target), Buffer::Length(target)); @@ -161,7 +162,8 @@ NAN_METHOD(convert_blob) { // (parentBlockBuffer, cnBlobType) NAN_METHOD(get_block_id) { if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = info[0]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); blobdata input = std::string(Buffer::Data(target), Buffer::Length(target)); @@ -187,8 +189,9 @@ NAN_METHOD(get_block_id) { NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, cnBlobType) if (info.Length() < 2) return THROW_ERROR_EXCEPTION("You must provide two arguments."); - Local block_template_buf = info[0]->ToObject(); - Local nonce_buf = info[1]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local block_template_buf = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + Local nonce_buf = info[1]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(block_template_buf) || !Buffer::HasInstance(nonce_buf)) return THROW_ERROR_EXCEPTION("Both arguments should be buffer objects."); @@ -219,7 +222,7 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c if (blob_type == BLOB_TYPE_CRYPTONOTE_XTNC || blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO) { if (info.Length() != 4) return THROW_ERROR_EXCEPTION("You must provide 4 arguments."); Local cycle = Local::Cast(info[3]); - for (int i = 0; i < 32; i++ ) b.cycle.data[i] = cycle->Get(i)->NumberValue(); + for (int i = 0; i < 32; i++ ) b.cycle.data[i] = cycle->Get(i)->NumberValue(isolate->GetCurrentContext()).ToChecked(); } if (!block_to_blob(b, output)) return THROW_ERROR_EXCEPTION("Failed to convert block to blob"); @@ -231,7 +234,8 @@ NAN_METHOD(construct_block_blob) { // (parentBlockTemplateBuffer, nonceBuffer, c NAN_METHOD(address_decode) { if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = info[0]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -261,7 +265,8 @@ NAN_METHOD(address_decode) { NAN_METHOD(address_decode_integrated) { if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); - Local target = info[0]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); @@ -296,8 +301,9 @@ NAN_METHOD(get_merged_mining_nonce_size) { NAN_METHOD(construct_mm_parent_block_blob) { // (parentBlockTemplate, blob_type, childBlockTemplate) if (info.Length() < 3) return THROW_ERROR_EXCEPTION("You must provide three arguments (parentBlock, blob_type, childBlock)."); - Local target = info[0]->ToObject(); - Local child_target = info[2]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + Local child_target = info[2]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("First argument should be a buffer object."); if (!info[1]->IsNumber()) return THROW_ERROR_EXCEPTION("Second argument should be a number"); @@ -329,8 +335,9 @@ NAN_METHOD(construct_mm_parent_block_blob) { // (parentBlockTemplate, blob_type, NAN_METHOD(construct_mm_child_block_blob) { // (shareBuffer, blob_type, childBlockTemplate) if (info.Length() < 3) return THROW_ERROR_EXCEPTION("You must provide three arguments (shareBuffer, blob_type, block2)."); - Local block_template_buf = info[0]->ToObject(); - Local child_block_template_buf = info[2]->ToObject(); + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + Local block_template_buf = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + Local child_block_template_buf = info[2]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); if (!Buffer::HasInstance(block_template_buf)) return THROW_ERROR_EXCEPTION("First argument should be a buffer object."); if (!info[1]->IsNumber()) return THROW_ERROR_EXCEPTION("Second argument should be a number");