btcrelay-bitcoind
Advanced tools
Comparing version 3.0.12 to 3.1.0
@@ -42,6 +42,14 @@ "use strict"; | ||
const computedHeaderMap = {}; | ||
const saveHeaders = (headerCache) => __awaiter(this, void 0, void 0, function* () { | ||
const saveHeaders = (headerCache, final) => __awaiter(this, void 0, void 0, function* () { | ||
console.log("[BtcRelaySynchronizer]: Header cache: ", headerCache.map(e => e.hash)); | ||
if (cacheData.forkId === -1) { | ||
cacheData = yield this.btcRelay.saveNewForkHeaders(headerCache, cacheData.lastStoredHeader, tipData.chainWork); | ||
if (final && | ||
this.btcRelay.maxShortForkHeadersPerTx != null && | ||
this.btcRelay.maxShortForkHeadersPerTx >= headerCache.length && | ||
this.btcRelay.saveShortForkHeaders != null) { | ||
cacheData = yield this.btcRelay.saveShortForkHeaders(headerCache, cacheData.lastStoredHeader, tipData.chainWork); | ||
} | ||
else { | ||
cacheData = yield this.btcRelay.saveNewForkHeaders(headerCache, cacheData.lastStoredHeader, tipData.chainWork); | ||
} | ||
} | ||
@@ -69,3 +77,3 @@ else if (cacheData.forkId === 0) { | ||
headerCache.length >= this.btcRelay.maxForkHeadersPerTx) { | ||
yield saveHeaders(headerCache); | ||
yield saveHeaders(headerCache, false); | ||
headerCache = []; | ||
@@ -79,3 +87,3 @@ } | ||
if (headerCache.length > 0) { | ||
yield saveHeaders(headerCache); | ||
yield saveHeaders(headerCache, true); | ||
} | ||
@@ -82,0 +90,0 @@ return { |
{ | ||
"name": "btcrelay-bitcoind", | ||
"version": "3.0.12", | ||
"version": "3.1.0", | ||
"description": "Connector and synchronizer using bitcoind for bitcoin relay", | ||
@@ -25,9 +25,11 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@types/node": "^18.15.11", | ||
"bitcoind-rpc": "^0.9.1", | ||
"bitcoinjs-lib": "^5.2.0", | ||
"bn.js": "^5.2.1", | ||
"crosslightning-base": "^4.0.8", | ||
"crosslightning-base": "^4.0.9" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.18.3", | ||
"typescript": "^4.9.5" | ||
} | ||
} |
@@ -59,6 +59,15 @@ | ||
const saveHeaders = async (headerCache: BitcoindBlock[]) => { | ||
const saveHeaders = async (headerCache: BitcoindBlock[], final: boolean) => { | ||
console.log("[BtcRelaySynchronizer]: Header cache: ", headerCache.map(e => e.hash)); | ||
if(cacheData.forkId===-1) { | ||
cacheData = await this.btcRelay.saveNewForkHeaders(headerCache, cacheData.lastStoredHeader, tipData.chainWork) | ||
if( | ||
final && | ||
this.btcRelay.maxShortForkHeadersPerTx!=null && | ||
this.btcRelay.maxShortForkHeadersPerTx>=headerCache.length && | ||
this.btcRelay.saveShortForkHeaders!=null | ||
) { | ||
cacheData = await this.btcRelay.saveShortForkHeaders(headerCache, cacheData.lastStoredHeader, tipData.chainWork); | ||
} else { | ||
cacheData = await this.btcRelay.saveNewForkHeaders(headerCache, cacheData.lastStoredHeader, tipData.chainWork); | ||
} | ||
} else if(cacheData.forkId===0) { | ||
@@ -91,3 +100,3 @@ cacheData = await this.btcRelay.saveMainHeaders(headerCache, cacheData.lastStoredHeader); | ||
await saveHeaders(headerCache); | ||
await saveHeaders(headerCache, false); | ||
@@ -105,3 +114,3 @@ headerCache = []; | ||
if(headerCache.length>0) { | ||
await saveHeaders(headerCache); | ||
await saveHeaders(headerCache, true); | ||
} | ||
@@ -108,0 +117,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49240
4
993
2
- Removed@types/node@^18.15.11
- Removedtypescript@^4.9.5
- Removed@types/node@18.19.64(transitive)
- Removedtypescript@4.9.5(transitive)
- Removedundici-types@5.26.5(transitive)
Updatedcrosslightning-base@^4.0.9