Skip to content

Commit

Permalink
Merge pull request #1 from hybridnetwork/add-bliss-support
Browse files Browse the repository at this point in the history
Add bliss support
  • Loading branch information
thearagog authored Feb 15, 2018
2 parents e0920d4 + 4977048 commit f788e23
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ EXPOSE 3004
ENV BITCOIND_USER user
ENV BITCOIND_PASS pass
ENV BITCOIND_HOST dcrd
ENV INSIGHT_NETWORK dcrdtestnet
ENV INSIGHT_NETWORK hxtestnet
ENV LOGGER_LEVEL debug
ENV INSIGHT_FORCE_RPC_SYNC 1
ENV PATH $HOME/.nvm/$NODE_VERSION/bin:$PATH
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ BITCOIND_P2P_PORT # P2P bitcoind Port
BITCOIND_USER # RPC username
BITCOIND_PASS # RPC password
BITCOIND_DATADIR # bitcoind datadir. 'testnet3' will be appended automatically if testnet is used. NEED to finish with '/'. e.g: `/vol/data/`
INSIGHT_NETWORK [= 'livenet' | 'testnet' | 'btcdlivenet' | 'btcdtestnet' | 'dcrdlivenet' | 'dcrdtestnet' ]
INSIGHT_NETWORK [= 'livenet' | 'testnet' | 'btcdlivenet' | 'btcdtestnet' | 'hxlivenet' | 'hxtestnet']
INSIGHT_PORT # insight api port
INSIGHT_DB # Path where to store insight's internal DB. (defaults to $HOME/.insight)
INSIGHT_SAFE_CONFIRMATIONS=6 # Nr. of confirmation needed to start caching transaction information
Expand Down
16 changes: 16 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ case 'dcrdtestnet':
b_port = '19109';
p2p_port = '19108';
break;
case 'hxlivenet':
env = 'hxlivenet';
var network = 'hxlivenet';
db = home + '/hxd';
port = '3005';
b_port = '1409';
p2p_port = '1408';
break;
case 'hxtestnet':
env = 'hxtestnet';
var network = 'hxtestnet';
db = home + '/hxtestnet';
port = '3006';
b_port = '12009';
p2p_port = '12008';
break;
}
port = parseInt(process.env.INSIGHT_PORT) || port;

Expand Down
2 changes: 1 addition & 1 deletion dev-util/read_block.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var assert = require('assert'),
util = require('bitcore/util/util');

var be = new BlockExtractor(config.bitcoind.dataDir, config.network);
var network = config.network === 'dcrdtestnet' ? networks.dcrdtestnet: networks.dcrdlivenet;
var network = networks[config.network];
// console.log('[read_block.js.13]', be.nextFile() );

var c=0;
Expand Down
2 changes: 1 addition & 1 deletion lib/BlockExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function BlockExtractor(dataDir, network) {
this.isCurrentRead = false;
this.currentBuffer = null;
this.currentParser = null;
this.network = network === 'dcrdtestnet' ? networks.drcdtestnet: networks.dcrdlivenet;
this.network = network[networks.drcdtestnet];
this.magic = this.network.magic.toString('hex');
}

Expand Down
7 changes: 6 additions & 1 deletion lib/HistoricSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ function HistoricSync(opts) {
case 'dcrdtestnet':
this.network = networks.dcrdtestnet;
break;
case 'hxlivenet':
this.network = networks.hxlivenet;
break;
case 'hxtestnet':
this.network = networks.hxtestnet;
}

var genesisHashReversed = new Buffer(32);
Expand Down Expand Up @@ -273,7 +278,7 @@ HistoricSync.prototype.updateStartBlock = function(opts, next) {
var ret = false;

var d = Math.abs(height - blockInfo.height);
var limit = self.network == 'dcrdlivenet' ? 6 : 100;
var limit = self.network == 'hxlivenet' ? 6 : 100;
if (d > limit) {
error('Previous Tip block height differs by %d. Please delete and resync (-D)', d);
process.exit(1);
Expand Down
30 changes: 24 additions & 6 deletions lib/Rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Rpc._parseTxResult = function(info) {
info.agendas = new Array();
var wrongVoteVersion = 'Wrong vote version';

if (config.network == 'dcrdlivenet') {
if (config.network == 'dcrdlivenet' || config.network == 'hxlivenet') {
// Agendas for mainnet vote version 4
if (parseInt(hexLE, 16) == 4) {
var lnsupportMask = 0x18;
Expand All @@ -80,7 +80,7 @@ Rpc._parseTxResult = function(info) {
} else {
info.agendas.push(wrongVoteVersion);
}
} else if (config.network == 'dcrdtestnet') {
} else if (config.network == 'dcrdtestnet' || config.network == 'hxtestnet') {
// Agendas for mainnet vote version 5
if (parseInt(hexLE, 16) == 5) {
var sdiffMask=0x06;
Expand Down Expand Up @@ -190,6 +190,24 @@ Rpc.getBlock = function(hash, cb) {
stakeProportion = 3;
taxProportion = 1;
break;
case 'hxlivenet':
reductionInterval = 6144;
base = 3119582664;
mulSubsidy = 100;
divSubsidy = 101;
workProportion = 6;
stakeProportion = 3;
taxProportion = 1;
break;
case 'hxtestnet':
reductionInterval = 2048;
base = 2500000000;
mulSubsidy = 100;
divSubsidy = 101;
workProportion = 6;
stakeProportion = 3;
taxProportion = 1;
break;
default:
reductionInterval = 1;
base = 1;
Expand Down Expand Up @@ -222,13 +240,13 @@ Rpc.getBlock = function(hash, cb) {
if (info.result.height == 0) {
info.result.reward = 0;
} else if (info.result.height == 1) {
if (config.network === 'dcrdlivenet') {
info.result.reward = 1680000;
} else if (config.network === 'dcrdtestnet') {
if (config.network === 'dcrdlivenet' || config.network === 'hxlivenet') {
info.result.reward = 1680000;
} else if (config.network === 'dcrdtestnet' || config.network === 'hxtestnet') {
info.result.reward = 100000;
}
} else if ((info.result.height < 4096 && config.network === 'dcrdlivenet') ||
(info.result.height < 768 && config.network === 'dcrdtestnet')) {
(info.result.height < 768 && (config.network === 'dcrdtestnet' || config.network === 'hxtestnet'))) {
info.result.reward = Math.round(work + tax) / bitcore.util.COIN;
} else {
info.result.reward = Math.round(work + stake + tax) / bitcore.util.COIN;
Expand Down
2 changes: 1 addition & 1 deletion lib/Sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Sync(opts) {
this.opts = opts || {};
this.bDb = require('./BlockDb').default();
this.txDb = require('./TransactionDb').default();
this.network = config.network === 'dcrdtestnet' ? networks.dcrdtestnet : networks.dcrdlivenet;
this.network = networks[config.network];
this.cachedLastHash = null;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/TransactionDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var Address = require('soop').load('bitcore/lib/Address', {

var TransactionDb = function() {
TransactionDb.super(this, arguments);
this.network = config.network === 'dcrdtestnet' ? networks.dcrdtestnet : networks.dcrdlivenet;
this.network = networks[config.network];
this.poolMatch = new PoolMatch();
this.safeConfirmations = config.safeConfirmations || DEFAULT_SAFE_CONFIRMATIONS;

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
},
"dependencies": {
"async": "*",
"base58-native": "0.1.2",
"base58-native": "0.1.4",
"bignum": "*",
"morgan": "*",
"bitcore": "git://github.com/decred/bitcore.git#master-legacy",
"bitcore": "git://github.com/hybridnetwork/bitcore.git#master-legacy",
"bufferput": "git://github.com/bitpay/node-bufferput.git",
"buffertools": "*",
"commander": "^2.3.0",
Expand Down

0 comments on commit f788e23

Please sign in to comment.