Use node::Buffer directly, fix arg check

It was failing on node 0.12.
This commit is contained in:
Kagami Hiiragi 2015-07-13 22:09:50 +03:00
parent a8be4c88b5
commit 4833621f9b

View File

@ -2,7 +2,6 @@
#include <nan.h> #include <nan.h>
#include "./pow.h" #include "./pow.h"
using node::Buffer;
using v8::Handle; using v8::Handle;
using v8::Local; using v8::Local;
using v8::FunctionTemplate; using v8::FunctionTemplate;
@ -70,15 +69,15 @@ NAN_METHOD(PowAsync) {
if (args.Length() != 4 || if (args.Length() != 4 ||
!args[0]->IsNumber() || // pool_size !args[0]->IsNumber() || // pool_size
!args[1]->IsNumber() || // target !args[1]->IsNumber() || // target
!args[2]->IsObject() || // initial_hash !node::Buffer::HasInstance(args[2]) || // initial_hash
!args[3]->IsFunction()) { // cb !args[3]->IsFunction()) { // cb
return NanThrowError("Bad input"); return NanThrowError("Bad input");
} }
size_t pool_size = args[0]->Uint32Value(); size_t pool_size = args[0]->Uint32Value();
uint64_t target = args[1]->IntegerValue(); uint64_t target = args[1]->IntegerValue();
char* buf = Buffer::Data(args[2]->ToObject()); char* buf = node::Buffer::Data(args[2]);
size_t length = Buffer::Length(args[2]->ToObject()); size_t length = node::Buffer::Length(args[2]);
if (pool_size < 1 || if (pool_size < 1 ||
pool_size > MAX_POOL_SIZE || pool_size > MAX_POOL_SIZE ||
buf == NULL || buf == NULL ||