diff --git a/src/pow.h b/src/pow.h index 28bc894..78fc665 100644 --- a/src/pow.h +++ b/src/pow.h @@ -1,8 +1,8 @@ #ifndef BITMESSAGE_POW_H #define BITMESSAGE_POW_H -#define MAX_POOL_SIZE 1024 -#define HASH_SIZE 64 +static const int MAX_POOL_SIZE = 1024; +static const int HASH_SIZE = 64; int pow(size_t pool_size, uint64_t target, diff --git a/src/worker.cc b/src/worker.cc index d159f92..01bfb26 100644 --- a/src/worker.cc +++ b/src/worker.cc @@ -2,8 +2,6 @@ #include #include "./pow.h" -#define MAX_SAFE_INTEGER 9007199254740991 - using node::Buffer; using v8::Handle; using v8::Local; @@ -14,6 +12,8 @@ using v8::Object; using v8::String; using v8::Integer; +static const uint64_t MAX_SAFE_INTEGER = 9007199254740991ULL; + class PowWorker : public NanAsyncWorker { public: PowWorker(NanCallback* callback, @@ -77,13 +77,12 @@ NAN_METHOD(PowAsync) { size_t pool_size = args[0]->Uint32Value(); uint64_t target = args[1]->IntegerValue(); - size_t length = Buffer::Length(args[2]->ToObject()); char* buf = Buffer::Data(args[2]->ToObject()); - if ( - pool_size < 1 || + size_t length = Buffer::Length(args[2]->ToObject()); + if (pool_size < 1 || pool_size > MAX_POOL_SIZE || - length != HASH_SIZE || - buf == NULL) { + buf == NULL || + length != HASH_SIZE) { return NanThrowError("Bad input"); }