minor changes.
This commit is contained in:
parent
1eafe41bab
commit
2577fa0229
@ -344,8 +344,6 @@ Bitcoin.prototype.close = function(callback) {
|
|||||||
* Block
|
* Block
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var _blockFlag = {};
|
|
||||||
|
|
||||||
function Block(data) {
|
function Block(data) {
|
||||||
if (!(this instanceof Block)) {
|
if (!(this instanceof Block)) {
|
||||||
return new Block(data);
|
return new Block(data);
|
||||||
@ -377,11 +375,11 @@ Object.defineProperty(Block.prototype, '_blockFlag', {
|
|||||||
configurable: false,
|
configurable: false,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
writable: false,
|
writable: false,
|
||||||
value: _blockFlag
|
value: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
Block.isBlock = function(block) {
|
Block.isBlock = function(block) {
|
||||||
return block._blockFlag === _blockFlag;
|
return block._blockFlag === Block.prototype._blockFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
Block.fromHex = function(hex) {
|
Block.fromHex = function(hex) {
|
||||||
@ -429,8 +427,6 @@ Block.toBinary = function(block) {
|
|||||||
* Transaction
|
* Transaction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var _txFlag = {};
|
|
||||||
|
|
||||||
function Transaction(data) {
|
function Transaction(data) {
|
||||||
if (!(this instanceof Transaction)) {
|
if (!(this instanceof Transaction)) {
|
||||||
return new Transaction(data);
|
return new Transaction(data);
|
||||||
@ -458,12 +454,12 @@ Object.defineProperty(Transaction.prototype, '_txFlag', {
|
|||||||
configurable: false,
|
configurable: false,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
writable: false,
|
writable: false,
|
||||||
value: _txFlag
|
value: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
Transaction.isTransaction =
|
Transaction.isTransaction =
|
||||||
Transaction.isTx = function(tx) {
|
Transaction.isTx = function(tx) {
|
||||||
return tx._txFlag === _txFlag;
|
return tx._txFlag === Transaction.prototype._txFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.fromHex = function(hex) {
|
Transaction.fromHex = function(hex) {
|
||||||
|
|||||||
@ -128,8 +128,6 @@ extern const std::string strMessageMagic;
|
|||||||
using namespace node;
|
using namespace node;
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
|
||||||
Handle<Object> bitcoindjs_obj;
|
|
||||||
|
|
||||||
NAN_METHOD(StartBitcoind);
|
NAN_METHOD(StartBitcoind);
|
||||||
NAN_METHOD(IsStopping);
|
NAN_METHOD(IsStopping);
|
||||||
NAN_METHOD(IsStopped);
|
NAN_METHOD(IsStopped);
|
||||||
@ -170,13 +168,13 @@ NAN_METHOD(WalletSetTxFee);
|
|||||||
NAN_METHOD(WalletImportKey);
|
NAN_METHOD(WalletImportKey);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
async_start_node_work(uv_work_t *req);
|
async_start_node(uv_work_t *req);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
async_start_node_after(uv_work_t *req);
|
async_start_node_after(uv_work_t *req);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
async_stop_node_work(uv_work_t *req);
|
async_stop_node(uv_work_t *req);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
async_stop_node_after(uv_work_t *req);
|
async_stop_node_after(uv_work_t *req);
|
||||||
@ -398,7 +396,7 @@ NAN_METHOD(StartBitcoind) {
|
|||||||
req->data = data;
|
req->data = data;
|
||||||
|
|
||||||
int status = uv_queue_work(uv_default_loop(),
|
int status = uv_queue_work(uv_default_loop(),
|
||||||
req, async_start_node_work,
|
req, async_start_node,
|
||||||
(uv_after_work_cb)async_start_node_after);
|
(uv_after_work_cb)async_start_node_after);
|
||||||
|
|
||||||
assert(status == 0);
|
assert(status == 0);
|
||||||
@ -407,12 +405,12 @@ NAN_METHOD(StartBitcoind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* async_start_node_work()
|
* async_start_node()
|
||||||
* Call start_node() and start all our boost threads.
|
* Call start_node() and start all our boost threads.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
async_start_node_work(uv_work_t *req) {
|
async_start_node(uv_work_t *req) {
|
||||||
async_node_data *data = static_cast<async_node_data*>(req->data);
|
async_node_data *data = static_cast<async_node_data*>(req->data);
|
||||||
start_node();
|
start_node();
|
||||||
data->result = std::string("start_node(): bitcoind opened.");
|
data->result = std::string("start_node(): bitcoind opened.");
|
||||||
@ -565,7 +563,7 @@ NAN_METHOD(StopBitcoind) {
|
|||||||
req->data = data;
|
req->data = data;
|
||||||
|
|
||||||
int status = uv_queue_work(uv_default_loop(),
|
int status = uv_queue_work(uv_default_loop(),
|
||||||
req, async_stop_node_work,
|
req, async_stop_node,
|
||||||
(uv_after_work_cb)async_stop_node_after);
|
(uv_after_work_cb)async_stop_node_after);
|
||||||
|
|
||||||
assert(status == 0);
|
assert(status == 0);
|
||||||
@ -574,12 +572,12 @@ NAN_METHOD(StopBitcoind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* async_stop_node_work()
|
* async_stop_node()
|
||||||
* Call StartShutdown() to join the boost threads, which will call Shutdown().
|
* Call StartShutdown() to join the boost threads, which will call Shutdown().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
async_stop_node_work(uv_work_t *req) {
|
async_stop_node(uv_work_t *req) {
|
||||||
async_node_data *data = static_cast<async_node_data*>(req->data);
|
async_node_data *data = static_cast<async_node_data*>(req->data);
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
data->result = std::string("stop_node(): bitcoind shutdown.");
|
data->result = std::string("stop_node(): bitcoind shutdown.");
|
||||||
@ -2509,7 +2507,8 @@ cblock_to_jsblock(const CBlock& cblock, const CBlockIndex* cblock_index, Local<O
|
|||||||
CMerkleTx txGen(cblock.vtx[0]);
|
CMerkleTx txGen(cblock.vtx[0]);
|
||||||
txGen.SetMerkleBranch(&cblock);
|
txGen.SetMerkleBranch(&cblock);
|
||||||
jsblock->Set(NanNew<String>("confirmations"), NanNew<Number>((int)txGen.GetDepthInMainChain())->ToInt32());
|
jsblock->Set(NanNew<String>("confirmations"), NanNew<Number>((int)txGen.GetDepthInMainChain())->ToInt32());
|
||||||
jsblock->Set(NanNew<String>("size"), NanNew<Number>((int)::GetSerializeSize(cblock, SER_NETWORK, PROTOCOL_VERSION))->ToInt32());
|
jsblock->Set(NanNew<String>("size"),
|
||||||
|
NanNew<Number>((int)::GetSerializeSize(cblock, SER_NETWORK, PROTOCOL_VERSION))->ToInt32());
|
||||||
jsblock->Set(NanNew<String>("height"), NanNew<Number>(cblock_index->nHeight));
|
jsblock->Set(NanNew<String>("height"), NanNew<Number>(cblock_index->nHeight));
|
||||||
jsblock->Set(NanNew<String>("version"), NanNew<Number>(cblock.nVersion));
|
jsblock->Set(NanNew<String>("version"), NanNew<Number>(cblock.nVersion));
|
||||||
jsblock->Set(NanNew<String>("merkleroot"), NanNew<String>(cblock.hashMerkleRoot.GetHex()));
|
jsblock->Set(NanNew<String>("merkleroot"), NanNew<String>(cblock.hashMerkleRoot.GetHex()));
|
||||||
@ -2830,8 +2829,6 @@ extern "C" void
|
|||||||
init(Handle<Object> target) {
|
init(Handle<Object> target) {
|
||||||
NanScope();
|
NanScope();
|
||||||
|
|
||||||
bitcoindjs_obj = target;
|
|
||||||
|
|
||||||
NODE_SET_METHOD(target, "start", StartBitcoind);
|
NODE_SET_METHOD(target, "start", StartBitcoind);
|
||||||
NODE_SET_METHOD(target, "stop", StopBitcoind);
|
NODE_SET_METHOD(target, "stop", StopBitcoind);
|
||||||
NODE_SET_METHOD(target, "stopping", IsStopping);
|
NODE_SET_METHOD(target, "stopping", IsStopping);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user