Merge pull request #29 from kleetus/chainActive
1. Added a way to check if the genesis block is ready in chainActive …
This commit is contained in:
commit
fa3700babf
@ -23,7 +23,7 @@ describe('Basic Functionality', function() {
|
|||||||
before(function(done) {
|
before(function(done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
bitcoind = require('../')({
|
bitcoind = require('../')({
|
||||||
directory: '~/.bitcoin',
|
directory: process.env.BITCOINDJS_DIR || '~/.bitcoin',
|
||||||
});
|
});
|
||||||
|
|
||||||
bitcoind.on('error', function(err) {
|
bitcoind.on('error', function(err) {
|
||||||
@ -55,13 +55,16 @@ describe('Basic Functionality', function() {
|
|||||||
tx.fromString(data);
|
tx.fromString(data);
|
||||||
it('for tx ' + tx.hash, function(done) {
|
it('for tx ' + tx.hash, function(done) {
|
||||||
bitcoind.getTransaction(tx.hash, function(err, response) {
|
bitcoind.getTransaction(tx.hash, function(err, response) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
assert(response.toString('hex') === data, 'incorrect tx data for ' + tx.hash);
|
assert(response.toString('hex') === data, 'incorrect tx data for ' + tx.hash);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('determine if outpoint is unspent/spent', function() {
|
describe('determine if outpoint is unspent/spent', function() {
|
||||||
spentData.forEach(function(data) {
|
spentData.forEach(function(data) {
|
||||||
it('for spent txid ' + data.txid + ' and output ' + data.outputIndex, function() {
|
it('for spent txid ' + data.txid + ' and output ' + data.outputIndex, function() {
|
||||||
@ -79,7 +82,7 @@ describe('Basic Functionality', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('get blocks by hash', function() {
|
describe('get blocks by hash', function() {
|
||||||
|
|
||||||
blockData.forEach(function(data) {
|
blockData.forEach(function(data) {
|
||||||
var block = bitcore.Block.fromString(data);
|
var block = bitcore.Block.fromString(data);
|
||||||
it('block ' + block.hash, function(done) {
|
it('block ' + block.hash, function(done) {
|
||||||
|
|||||||
@ -64,9 +64,6 @@ async_get_tx(uv_work_t *req);
|
|||||||
static void
|
static void
|
||||||
async_get_tx_after(uv_work_t *req);
|
async_get_tx_after(uv_work_t *req);
|
||||||
|
|
||||||
static int
|
|
||||||
get_tx(uint256 txid, uint256& blockhash, CTransaction& ctx);
|
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
init(Handle<Object>);
|
init(Handle<Object>);
|
||||||
|
|
||||||
@ -139,83 +136,6 @@ struct async_tx_data {
|
|||||||
Eternal<Function> callback;
|
Eternal<Function> callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* async_block_tx_data
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct async_block_tx_data {
|
|
||||||
std::string err_msg;
|
|
||||||
std::string txid;
|
|
||||||
CBlock cblock;
|
|
||||||
CBlockIndex* cblock_index;
|
|
||||||
CTransaction ctx;
|
|
||||||
Eternal<Function> callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* async_block_time_data
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _cblocks_list {
|
|
||||||
CBlock cblock;
|
|
||||||
CBlockIndex* cblock_index;
|
|
||||||
struct _cblocks_list *next;
|
|
||||||
std::string err_msg;
|
|
||||||
} cblocks_list;
|
|
||||||
|
|
||||||
struct async_block_time_data {
|
|
||||||
std::string err_msg;
|
|
||||||
uint32_t gte;
|
|
||||||
uint32_t lte;
|
|
||||||
int64_t limit;
|
|
||||||
cblocks_list *cblocks;
|
|
||||||
Eternal<Function> callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* async_addrtx_data
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _ctx_list {
|
|
||||||
CTransaction ctx;
|
|
||||||
uint256 blockhash;
|
|
||||||
struct _ctx_list *next;
|
|
||||||
std::string err_msg;
|
|
||||||
} ctx_list;
|
|
||||||
|
|
||||||
struct async_addrtx_data {
|
|
||||||
std::string err_msg;
|
|
||||||
std::string addr;
|
|
||||||
ctx_list *ctxs;
|
|
||||||
int64_t blockheight;
|
|
||||||
int64_t blocktime;
|
|
||||||
Eternal<Function> callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* async_broadcast_tx_data
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct async_broadcast_tx_data {
|
|
||||||
std::string err_msg;
|
|
||||||
Eternal<Object> jstx;
|
|
||||||
CTransaction ctx;
|
|
||||||
std::string txid;
|
|
||||||
bool override_fees;
|
|
||||||
bool own_only;
|
|
||||||
Eternal<Function> callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* async_from_tx_data
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct async_from_tx_data {
|
|
||||||
std::string err_msg;
|
|
||||||
std::string txid;
|
|
||||||
ctx_list *ctxs;
|
|
||||||
Eternal<Function> callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpers
|
* Helpers
|
||||||
@ -276,6 +196,9 @@ async_blocks_ready(uv_work_t *req) {
|
|||||||
usleep(1E6);
|
usleep(1E6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(chainActive[0] == NULL) {
|
||||||
|
usleep(1E6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user