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) {
|
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) {
|
} catch (e) {
|
||||||
logger.warn('Failed to parse rbf cache. Skipping. Reason: ' + (e instanceof Error ? e.message : e));
|
logger.warn('Failed to parse rbf cache. Skipping. Reason: ' + (e instanceof Error ? e.message : e));
|
||||||
|
@ -368,21 +368,25 @@ class RbfCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async load({ txs, trees, expiring }): Promise<void> {
|
public async load({ txs, trees, expiring }): Promise<void> {
|
||||||
txs.forEach(txEntry => {
|
try {
|
||||||
this.txs.set(txEntry.value.txid, txEntry.value);
|
txs.forEach(txEntry => {
|
||||||
});
|
this.txs.set(txEntry.value.txid, txEntry.value);
|
||||||
this.staleCount = 0;
|
});
|
||||||
for (const deflatedTree of trees) {
|
this.staleCount = 0;
|
||||||
await this.importTree(deflatedTree.root, deflatedTree.root, deflatedTree, this.txs);
|
for (const deflatedTree of trees) {
|
||||||
}
|
await this.importTree(deflatedTree.root, deflatedTree.root, deflatedTree, this.txs);
|
||||||
expiring.forEach(expiringEntry => {
|
|
||||||
if (this.txs.has(expiringEntry.key)) {
|
|
||||||
this.expiring.set(expiringEntry.key, new Date(expiringEntry.value).getTime());
|
|
||||||
}
|
}
|
||||||
});
|
expiring.forEach(expiringEntry => {
|
||||||
logger.debug(`loaded ${txs.length} txs, ${trees.length} trees into rbf cache, ${expiring.length} due to expire, ${this.staleCount} were stale`);
|
if (this.txs.has(expiringEntry.key)) {
|
||||||
this.staleCount = 0;
|
this.expiring.set(expiringEntry.key, new Date(expiringEntry.value).getTime());
|
||||||
this.cleanup();
|
}
|
||||||
|
});
|
||||||
|
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) {
|
exportTree(tree: RbfTree, deflated: any = null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user