Merge pull request #27 from braydonf/chainactiveready

Handle case that chainActive at height does not exist.
This commit is contained in:
Chris Kleeschulte 2015-07-16 11:01:50 -04:00
commit 24885211e9
2 changed files with 7 additions and 0 deletions

View File

@ -85,6 +85,9 @@ describe('Basic Functionality', function() {
knownHeights.forEach(function(data) {
it('block at height ' + data[0], function(done) {
bitcoind.getBlock(data[0], function(err, response) {
if (err) {
throw err;
}
var block = bitcore.Block.fromBuffer(response);
block.hash.should.equal(data[1]);
done();

View File

@ -743,6 +743,10 @@ async_get_block(uv_work_t *req) {
if (data->height != -1) {
pblockindex = chainActive[data->height];
if (pblockindex == NULL) {
data->err_msg = std::string("Block not found.");
return;
}
} else {
if (mapBlockIndex.count(hash) == 0) {
data->err_msg = std::string("Block not found.");