Commit ff0ea3fa authored by Jeremy Bokobza's avatar Jeremy Bokobza

added isChainsynced

the logic is that if isChainSynced == true then you can calculate the percentage based on ChainTip and LastBlockSyncedHeight
if isChainSynced == false you can't because we don't know yet how long the chain is
parent 2bb8f4c4
<div class="status">
<ul class="list-inline align-self-center row" title="Total blocks: {{ chainTip }}&#013;Last block received: {{ lastBlockSyncedHeight }}&#013;Connections: {{ connectedNodes }}">
<li class="list-inline-item pending"><i class="icon-syncr text-success"></i></li>
<li class="list-inline-item">{{ percentSynced }}%</li>
<li class="list-inline-item">{{ percentSynced }}</li>
<li class="list-inline-item"><i class="icon-earth text-success"></i></li>
<li class="list-inline-item">{{ connectedNodes }}</li>
</ul>
......
......@@ -17,6 +17,7 @@ export class StatusBarComponent implements OnInit {
private generalWalletInfoSubscription: Subscription;
private lastBlockSyncedHeight: number;
private chainTip: number;
private isChainSynced: boolean;
private connectedNodes: number = 0;
private percentSyncedNumber: number = 0;
private percentSynced: string;
......@@ -40,19 +41,20 @@ export class StatusBarComponent implements OnInit {
let generalWalletInfoResponse = response.json();
this.lastBlockSyncedHeight = generalWalletInfoResponse.lastBlockSyncedHeight;
this.chainTip = generalWalletInfoResponse.chainTip;
this.isChainSynced = generalWalletInfoResponse.isChainSynced;
this.connectedNodes = generalWalletInfoResponse.connectedNodes;
if (this.chainTip === 0) {
this.chainTip = 1;
}
this.percentSyncedNumber = ((this.lastBlockSyncedHeight / this.chainTip) * 100);
if (this.percentSyncedNumber.toFixed(0) === "100" && this.lastBlockSyncedHeight != this.chainTip) {
this.percentSyncedNumber = 99;
}
if(!this.isChainSynced) {
this.percentSynced = "syncing...";
}
else {
this.percentSyncedNumber = ((this.lastBlockSyncedHeight / this.chainTip) * 100);
if (this.percentSyncedNumber.toFixed(0) === "100" && this.lastBlockSyncedHeight != this.chainTip) {
this.percentSyncedNumber = 99;
}
this.percentSynced = this.percentSyncedNumber.toFixed(0);
this.percentSynced = this.percentSyncedNumber.toFixed(0) + "%";
}
}
},
error => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment