Compare commits

..

No commits in common. "be373552f5aee91b315ac42ac71ec9fc5e9e84be" and "f3606f2fe6cfe2767fce64d26678924fee5c66d9" have entirely different histories.

6 changed files with 25 additions and 114 deletions

View File

@ -855,9 +855,6 @@ class Chain extends AsyncEmitter {
assert(fork, 'No free space or data corruption.');
// Check NLR
if (await this.noLongReorg(tip, fork, competitor)) return true
// Blocks to disconnect.
const disconnect = [];
let entry = tip;
@ -915,9 +912,6 @@ class Chain extends AsyncEmitter {
assert(fork, 'No free space or data corruption.');
// Check NLR
if (await this.noLongReorg(tip, fork, competitor)) return true
// Buffer disconnected blocks.
const disconnect = [];
let entry = tip;
@ -956,48 +950,6 @@ class Chain extends AsyncEmitter {
return this.emitAsync('reorganize', tip, competitor);
}
/**
* Checks if a reorganization breaks the set nlrLimit,
* if it does, it invalidates necessary blocks and returns true
* else return false
* @param {ChainEntry} tip - Current tip of this chain.
* @param {ChainEntry} fork - The tip of the fork.
* @param {ChainEntry} competitor - The competing chain's tip.
* @returns {Promise<boolean>}
*/
async noLongReorg (tip, fork, competitor) {
if (tip.height - fork.height >= this.network.nlrLimit) {
if (this.network.nlrLimit !== 0) {
this.logger.warning(
'NLR Activated. Preventing reorganization: current=%h(%d) competitor=%h(%d) fork=%h(%d) reorg_size=%d nlr=%d',
tip.hash,
tip.height,
competitor.hash,
competitor.height,
fork.hash,
fork.height,
tip.height - fork.height,
this.network.nlrLimit
);
let indexWalk = competitor
// mark invalid_child from tip of competitor to first block of fork
while (indexWalk.height > fork.height) {
await this.setInvalid(indexWalk.hash)
indexWalk = await this.getPrevious(indexWalk)
}
// check
indexWalk = await this.getPrevious(indexWalk)
assert.strictEqual(indexWalk, fork)
return true
}
}
return false
}
/**
* Disconnect an entry from the chain (updates the tip).
* @param {ChainEntry} entry
@ -2257,7 +2209,7 @@ class Chain extends AsyncEmitter {
targetTimespan = pow.targetTimespan_Version1;
} else if ((prev.height + 1) < pow.blockHeight_Version3){
retargetInterval = pow.retargetInterval_Version2;
averagingInterval = pow.averagingInterval_Version2;
targetTimespan = pow.targetTimespan_Version2 * targetSpacing;
@ -2295,10 +2247,10 @@ class Chain extends AsyncEmitter {
// Back 6 block
var back = averagingInterval - 1;
if (prev.height + 1 !== averagingInterval)
back = averagingInterval;
let first = prev;
for (let i = 0; i < back; i++){
if (first)

View File

@ -12,7 +12,7 @@ const fs = require('bfile');
const IP = require('binet');
const dns = require('bdns');
const Logger = require('blgr');
const murmur3 = require('bcrypto/lib/murmur3');
const murmur3 = require('mrmr');
const List = require('blst');
const util = require('../utils/util');
const Network = require('../protocol/network');

View File

@ -58,7 +58,6 @@ class Network {
this.maxFeeRate = options.maxFeeRate;
this.selfConnect = options.selfConnect;
this.requestMempool = options.requestMempool;
this.nlrLimit = options.nlrLimit;
this.time = new TimeData();
this.init();

View File

@ -563,8 +563,6 @@ main.selfConnect = false;
main.requestMempool = false;
main.nlrLimit = 100 // 100 * ~40s = ~66 minutes
/*
* Testnet (v3)
* https://en.bitcoin.it/wiki/Testnet
@ -802,8 +800,6 @@ testnet.selfConnect = false;
testnet.requestMempool = false;
testnet.nlrLimit = 50; // 50 * ~40s = ~33 minutes
/*
* Regtest
*/
@ -1023,8 +1019,6 @@ regtest.selfConnect = true;
regtest.requestMempool = true;
regtest.nlrLimit = 10;
/*
* Simnet (btcd)
*/

69
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "fcoin",
"version": "1.1.4",
"version": "1.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -74,58 +74,13 @@
"integrity": "sha512-du2QjKNkqZ1YJweWEQeq3CEqd+nQD/WOnmAMfs52ok5ujBBagWYLZC5ORDuqfV2fuF88of44PZdsnAVfxoH31g=="
},
"bfilter": {
"version": "git+https://github.com/bcoin-org/bfilter.git#252b496e0057e1b59288efe8472fd021c74f5b91",
"from": "git+https://github.com/bcoin-org/bfilter.git#semver:~2.0.0",
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/bfilter/-/bfilter-1.0.5.tgz",
"integrity": "sha512-GupIidtCvLbKhXnA1sxvrwa+gh95qbjafy7P1U1x/2DHxNabXq4nGW0x3rmgzlJMYlVl+c8fMxoMRIwpKYlgcQ==",
"requires": {
"bcrypto": "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.0.3",
"bsert": "git+https://github.com/chjj/bsert.git#semver:~0.0.10",
"bufio": "git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6",
"loady": "git+https://github.com/chjj/loady.git#semver:~0.0.1",
"nan": "git+https://github.com/braydonf/nan.git#semver:~2.14.0"
},
"dependencies": {
"bcrypto": {
"version": "git+https://github.com/bcoin-org/bcrypto.git#0a01f693443d8b19f6db1154e0133c7bf703b205",
"from": "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.0.3",
"requires": {
"bufio": "~1.0.6",
"loady": "~0.0.1",
"nan": "^2.14.0"
},
"dependencies": {
"bufio": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/bufio/-/bufio-1.0.7.tgz",
"integrity": "sha512-bd1dDQhiC+bEbEfg56IdBv7faWa6OipMs/AFFFvtFnB3wAYjlwQpQRZ0pm6ZkgtfL0pILRXhKxOiQj6UzoMR7A=="
},
"loady": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/loady/-/loady-0.0.5.tgz",
"integrity": "sha512-uxKD2HIj042/HBx77NBcmEPsD+hxCgAtjEWlYNScuUjIsh/62Uyu39GOR68TBR68v+jqDL9zfftCWoUo4y03sQ=="
},
"nan": {
"version": "2.14.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz",
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ=="
}
}
},
"bsert": {
"version": "git+https://github.com/chjj/bsert.git#bd09d49eab8644bca08ae8259a3d8756e7d453fc",
"from": "git+https://github.com/chjj/bsert.git#semver:~0.0.10"
},
"bufio": {
"version": "git+https://github.com/bcoin-org/bufio.git#91ae6c93899ff9fad7d7cee9afd2a1c4933ca984",
"from": "git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6"
},
"loady": {
"version": "git+https://github.com/chjj/loady.git#b94958b7ee061518f4b85ea6da380e7ee93222d5",
"from": "git+https://github.com/chjj/loady.git#semver:~0.0.1"
},
"nan": {
"version": "git+https://github.com/braydonf/nan.git#1dcc61bd06d84e389bfd5311b2b1492a14c74201",
"from": "git+https://github.com/braydonf/nan.git#semver:~2.14.0"
}
"bsert": "~0.0.10",
"bufio": "~1.0.6",
"mrmr": "~0.1.6"
}
},
"bheep": {
@ -288,6 +243,16 @@
"resolved": "https://registry.npmjs.org/loady/-/loady-0.0.1.tgz",
"integrity": "sha512-PW5Z13Jd0v6ZcA1P6ZVUc3EV8BJwQuAiwUvvT6VQGHoaZ1d/tu7r1QZctuKfQqwy9SFBWeAGfcIdLxhp7ZW3Rw=="
},
"mrmr": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/mrmr/-/mrmr-0.1.8.tgz",
"integrity": "sha512-lNav10EJsPZvlMqlBOYQ5atIO9jrlvbJ4/7asqunXY89dHooN5c+W6AV7jtvBRw4wFDR7TpEWfmBQgRGRVwBzA==",
"requires": {
"bsert": "~0.0.10",
"loady": "~0.0.1",
"nan": "^2.13.1"
}
},
"n64": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/n64/-/n64-0.2.10.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "fcoin",
"version": "1.1.6",
"version": "1.1.4",
"description": "FLO bike-shed",
"license": "MIT",
"repository": "git://github.com/oipwg/fcoin.git",
@ -30,12 +30,12 @@
"dependencies": {
"bcfg": "~0.1.6",
"@oipwg/fclient": "~0.1.7",
"bcrypto": "~5.4.0",
"bcrypto": "~3.1.11",
"bdb": "~1.1.7",
"bdns": "~0.1.5",
"bevent": "~0.1.5",
"bfile": "~0.2.1",
"bfilter": "git+https://github.com/devonjames/bfilter.git",
"bfilter": "~1.0.5",
"bheep": "~0.1.5",
"binet": "~0.3.5",
"blgr": "~0.1.7",
@ -53,6 +53,7 @@
"bupnp": "~0.2.6",
"bval": "~0.1.6",
"bweb": "~0.1.9",
"mrmr": "~0.1.8",
"n64": "~0.2.10"
},
"devDependencies": {