fix chain.index.lastTs.
This commit is contained in:
parent
a7a8eb11bb
commit
bdc546edbc
@ -56,7 +56,7 @@ function Chain(options) {
|
|||||||
this.fromJSON(preload);
|
this.fromJSON(preload);
|
||||||
|
|
||||||
// Last TS after preload, needed for fill percent
|
// Last TS after preload, needed for fill percent
|
||||||
this.index.lastTs = this.index.ts[this.index.ts.length - 1];
|
this.index.lastTs = this.index.ts[0];
|
||||||
|
|
||||||
bcoin.chain.global = this;
|
bcoin.chain.global = this;
|
||||||
|
|
||||||
@ -212,7 +212,6 @@ Chain.prototype.resetHeight = function resetHeight(height) {
|
|||||||
this.index.hashes.forEach(function(hash) {
|
this.index.hashes.forEach(function(hash) {
|
||||||
self.index.bloom.add(hash, 'hex');
|
self.index.bloom.add(hash, 'hex');
|
||||||
});
|
});
|
||||||
this.index.lastTs = this.index.ts[this.index.ts.length - 1];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Chain.prototype._heightByTime = function _heightByTime(ts) {
|
Chain.prototype._heightByTime = function _heightByTime(ts) {
|
||||||
|
|||||||
@ -64,7 +64,7 @@ function Chain(options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Last TS after preload, needed for fill percent
|
// Last TS after preload, needed for fill percent
|
||||||
this.index.lastTs = this.index.entries[this.index.entries.length - 1].ts;
|
this.index.lastTs = this.index.entries[0].ts;
|
||||||
|
|
||||||
bcoin.chain.global = this;
|
bcoin.chain.global = this;
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ Chain.prototype.resetHeight = function resetHeight(height) {
|
|||||||
}, {});
|
}, {});
|
||||||
this.index.hashes.length = height + 1;
|
this.index.hashes.length = height + 1;
|
||||||
|
|
||||||
this.index.lastTs = this.index.entries[this.index.entries.length - 1].ts;
|
this.index.lastTs = this.index.entries[0].ts;
|
||||||
|
|
||||||
forked.forEach(function(entry) {
|
forked.forEach(function(entry) {
|
||||||
self._delete(entry);
|
self._delete(entry);
|
||||||
@ -348,7 +348,7 @@ Chain.prototype.isFull = function isFull() {
|
|||||||
|
|
||||||
Chain.prototype.fillPercent = function fillPercent() {
|
Chain.prototype.fillPercent = function fillPercent() {
|
||||||
var total = (+new Date() / 1000 - 40 * 60) - this.index.lastTs;
|
var total = (+new Date() / 1000 - 40 * 60) - this.index.lastTs;
|
||||||
var current = this.index.entries[this.index.entries.length - 1].ts - this.index.lastTs;
|
var current = this.getTip().ts - this.index.lastTs;
|
||||||
return Math.max(0, Math.min(current / total, 1));
|
return Math.max(0, Math.min(current / total, 1));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user