Update current block when new one is mined

This commit is contained in:
Râu Cao
2023-01-11 13:26:58 +08:00
parent 84dded2f10
commit ff716c68ea
+6 -3
View File
@@ -118,9 +118,12 @@ export default Service.extend({
}); });
await kredits.init(); await kredits.init();
this.set('kredits', kredits); this.set('kredits', kredits);
this.set('currentBlock', await kredits.provider.getBlockNumber()); this.set('currentBlock', await this.kredits.provider.getBlockNumber());
this.kredits.provider.on('block', blockNumber => {
console.debug('[kredits] New block mined:', blockNumber);
this.set('currentBlock', blockNumber)
});
if (this.currentUserAccounts && this.currentUserAccounts.length > 0) { if (this.currentUserAccounts && this.currentUserAccounts.length > 0) {
this.getCurrentUser.then(contributorData => { this.getCurrentUser.then(contributorData => {
@@ -738,5 +741,5 @@ export default Service.extend({
this.contributors this.contributors
.findBy('address', to) .findBy('address', to)
.incrementProperty('balance', value); .incrementProperty('balance', value);
}, }
}); });