Convert RBF disk cache data to match new format
This commit is contained in:
		
							parent
							
								
									0e420d8196
								
							
						
					
					
						commit
						e3e248d601
					
				@ -252,7 +252,11 @@ class DiskCache {
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (rbfData?.rbf) {
 | 
			
		||||
        rbfCache.load(rbfData.rbf);
 | 
			
		||||
        rbfCache.load({
 | 
			
		||||
          txs: rbfData.rbf.txs.map(([txid, entry]) => ({ value: entry })),
 | 
			
		||||
          trees: rbfData.rbf.trees,
 | 
			
		||||
          expiring: rbfData.rbf.expiring.map(([txid, value]) => ({ key: txid, value })),
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.warn('Failed to parse rbf cache. Skipping. Reason: ' + (e instanceof Error ? e.message : e));
 | 
			
		||||
 | 
			
		||||
@ -368,6 +368,7 @@ class RbfCache {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async load({ txs, trees, expiring }): Promise<void> {
 | 
			
		||||
    try {
 | 
			
		||||
      txs.forEach(txEntry => {
 | 
			
		||||
        this.txs.set(txEntry.value.txid, txEntry.value);
 | 
			
		||||
      });
 | 
			
		||||
@ -383,6 +384,9 @@ class RbfCache {
 | 
			
		||||
      logger.debug(`loaded ${txs.length} txs, ${trees.length} trees into rbf cache, ${expiring.length} due to expire, ${this.staleCount} were stale`);
 | 
			
		||||
      this.staleCount = 0;
 | 
			
		||||
      this.cleanup();
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.err('failed to restore RBF cache: ' + (e instanceof Error ? e.message : e));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  exportTree(tree: RbfTree, deflated: any = null) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user