Transition new blocks from the mempool onto the blockchain.

Chime on new blocks.
fixes #47
fixes #84
This commit is contained in:
softsimon
2020-06-10 23:52:14 +07:00
parent 7801fa7a24
commit e0a451eb05
22 changed files with 124 additions and 60 deletions

View File

@@ -113,19 +113,20 @@ export class TransactionComponent implements OnInit, OnDestroy {
});
this.stateService.blocks$
.subscribe((block) => this.latestBlock = block);
.subscribe(([block, txConfirmed]) => {
this.latestBlock = block;
this.stateService.txConfirmed$
.subscribe((block) => {
this.tx.status = {
confirmed: true,
block_height: block.height,
block_hash: block.id,
block_time: block.timestamp,
};
this.stateService.markBlock$.next({ blockHeight: block.height });
this.audioService.playSound('magic');
this.findBlockAndSetFeeRating();
if (txConfirmed) {
this.tx.status = {
confirmed: true,
block_height: block.height,
block_hash: block.id,
block_time: block.timestamp,
};
this.stateService.markBlock$.next({ blockHeight: block.height });
this.audioService.playSound('magic');
this.findBlockAndSetFeeRating();
}
});
this.stateService.txReplaced$
@@ -171,10 +172,10 @@ export class TransactionComponent implements OnInit, OnDestroy {
findBlockAndSetFeeRating() {
this.stateService.blocks$
.pipe(
filter((block) => block.height === this.tx.status.block_height),
filter(([block]) => block.height === this.tx.status.block_height),
take(1)
)
.subscribe((block) => {
.subscribe(([block]) => {
const feePervByte = this.tx.fee / (this.tx.weight / 4);
this.medianFeeNeeded = Math.round(block.feeRange[Math.round(block.feeRange.length * 0.5)]);