frontend resync recent blocks when necessary
This commit is contained in:
		
							parent
							
								
									ca6ddd609d
								
							
						
					
					
						commit
						eaad63a082
					
				@ -116,7 +116,7 @@ class WebsocketHandler {
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          // send initial data when a client first starts a subscription
 | 
			
		||||
          if (wantNow['want-blocks']) {
 | 
			
		||||
          if (wantNow['want-blocks'] || (parsedMessage && parsedMessage['refresh-blocks'])) {
 | 
			
		||||
            response['blocks'] = this.socketData['blocks'];
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -31,6 +31,7 @@ export interface WebsocketResponse {
 | 
			
		||||
  'track-rbf'?: string;
 | 
			
		||||
  'watch-mempool'?: boolean;
 | 
			
		||||
  'track-bisq-market'?: string;
 | 
			
		||||
  'refresh-blocks'?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ReplacedTransaction extends Transaction {
 | 
			
		||||
 | 
			
		||||
@ -235,6 +235,8 @@ export class WebsocketService {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  handleResponse(response: WebsocketResponse) {
 | 
			
		||||
    let reinitBlocks = false;
 | 
			
		||||
 | 
			
		||||
    if (response.blocks && response.blocks.length) {
 | 
			
		||||
      const blocks = response.blocks;
 | 
			
		||||
      let maxHeight = 0;
 | 
			
		||||
@ -256,9 +258,11 @@ export class WebsocketService {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (response.block) {
 | 
			
		||||
      if (response.block.height > this.stateService.latestBlockHeight) {
 | 
			
		||||
      if (response.block.height === this.stateService.latestBlockHeight + 1) {
 | 
			
		||||
        this.stateService.updateChainTip(response.block.height);
 | 
			
		||||
        this.stateService.blocks$.next([response.block, response.txConfirmed || '']);
 | 
			
		||||
      } else if (response.block.height > this.stateService.latestBlockHeight + 1) {
 | 
			
		||||
        reinitBlocks = true;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (response.txConfirmed) {
 | 
			
		||||
@ -369,5 +373,9 @@ export class WebsocketService {
 | 
			
		||||
    if (response['git-commit']) {
 | 
			
		||||
      this.stateService.backendInfo$.next(response['git-commit']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (reinitBlocks) {
 | 
			
		||||
      this.websocketSubject.next({'refresh-blocks': true});
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user