Skip to content

Commit

Permalink
fix VerifiedBlockchain.getBlockTime
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Dec 7, 2014
1 parent fbfd971 commit ce7acac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cc-wallet-core",
"version": "0.2.8",
"version": "0.2.9",
"description": "",
"main": "./src/index.js",
"keywords": [],
Expand Down
9 changes: 5 additions & 4 deletions src/blockchain/VerifiedBlockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ VerifiedBlockchain.prototype.getCurrentHeight = function() {
VerifiedBlockchain.prototype.getBlockTime = function(height, cb) {
verify.function(cb)

this._getVerifiedHeader(height)
.done(function(header) { cb(null, header.timestamp) }, function(error) { cb(error) })
this._getVerifiedHeader(height).then(function (header) {
return bitcoin.buffer2header(header).timestamp

}).done(function (ts) { cb(null, ts) }, function (error) { cb(error) })
}

/**
Expand Down Expand Up @@ -179,9 +181,8 @@ VerifiedBlockchain.prototype.clear = function() {
* @return {Q.Promise}
*/
VerifiedBlockchain.prototype._waitHeight = function(height) {
var self = this

var deferreds = this._waitHeightDeferreds[height] || []

deferreds.push(Q.defer())
this._waitHeightDeferreds[height] = deferreds

Expand Down
3 changes: 3 additions & 0 deletions src/history/HistoryManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ HistoryManager.prototype._addTx = function (tx) {
self._resortHistoryEntries()
self.emit('update')

}).catch(function (error) {
self.emit('error', error)

}).finally(function () {
self._syncExit()

Expand Down

0 comments on commit ce7acac

Please sign in to comment.