Skip to content

Commit

Permalink
blockchain: always enable segwit for regtest
Browse files Browse the repository at this point in the history
  • Loading branch information
braydonf authored and Mark Tyneway committed Jan 31, 2019
1 parent 8c9a188 commit 177403f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lib/blockchain/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,9 @@ class Chain extends AsyncEmitter {
async getState(prev, deployment) {
const bit = deployment.bit;

if (deployment.startTime === -1)
return thresholdStates.ACTIVE;

let window = this.network.minerWindow;
let threshold = this.network.activationThreshold;

Expand Down
6 changes: 3 additions & 3 deletions lib/blockchain/chaindb.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,13 @@ class ChainDB {
*/

writeDeployments(b) {
const bw = bio.write(1 + 17 * this.network.deploys.length);
const bw = bio.write(1 + 21 * this.network.deploys.length);

bw.writeU8(this.network.deploys.length);

for (const deployment of this.network.deploys) {
bw.writeU8(deployment.bit);
bw.writeU32(deployment.startTime);
bw.writeI64(deployment.startTime);
bw.writeU32(deployment.timeout);
bw.writeI32(deployment.threshold);
bw.writeI32(deployment.window);
Expand All @@ -671,7 +671,7 @@ class ChainDB {

for (let i = 0; i < count; i++) {
const bit = br.readU8();
const start = br.readU32();
const start = br.readI64();
const timeout = br.readU32();
const threshold = br.readI32();
const window = br.readI32();
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ regtest.deployments = {
segwit: {
name: 'segwit',
bit: 1,
startTime: 0,
startTime: -1,
timeout: 0xffffffff,
threshold: -1,
window: -1,
Expand Down
16 changes: 11 additions & 5 deletions test/http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,14 @@ describe('HTTP', function() {
});

it('should get a block template', async () => {
const json = await nclient.execute('getblocktemplate', []);
const json = await nclient.execute('getblocktemplate', [{
rules: ['segwit']
}]);
assert.deepStrictEqual(json, {
capabilities: ['proposal'],
mutable: ['time', 'transactions', 'prevblock'],
version: 536870912,
rules: [],
rules: ['!segwit'],
vbavailable: {},
vbrequired: 0,
height: 1,
Expand All @@ -222,15 +224,19 @@ describe('HTTP', function() {
mintime: 1296688603,
maxtime: json.maxtime,
expires: json.expires,
sigoplimit: 20000,
sizelimit: 1000000,
sigoplimit: 80000,
sizelimit: 4000000,
weightlimit: 4000000,
longpollid:
'0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206'
+ '00000000',
submitold: false,
coinbaseaux: { flags: '6d696e65642062792062636f696e' },
coinbasevalue: 5000000000,
transactions: []
transactions: [],
default_witness_commitment:
'6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48beb'
+ 'd836974e8cf9'
});
});

Expand Down

0 comments on commit 177403f

Please sign in to comment.