Skip to content

Commit

Permalink
V. 4.0.0 (#24)
Browse files Browse the repository at this point in the history
* Bump bitcore-lib to 0.15.3

* Feat : Added governance methods (deserialize, budget, votes, count,..)

* Impr : Removed autoinstaller

* Remove : Useless npm dependency

* Impr : Use uninstall method instead of npm

* Chore : bitcoind-rpc to dashd-rpc

* Chore : bitcore-lib => dashcore-lib

* Chore : bitcore-p2p => dashcore-p2p

* Impr : Dashified + Doc

* Fix : typo

* Impr : More Dashifying

* Impr : Even more dashifying

* Fix : Old bug

* Fix : Bug in logger test file

* Fix : Modify regtest for new path

* Impr : connect instead of spawn

* typo: s/need/needs/

* Updated docs and deps

* Update test for default conf integration

* Update deps

* Revert logger test cases

* linting impr

* Update npm lockfile

* Added log case for <node6

* Update travis file (#42)

* Doc : Dev Environment (#43)

* Bump to 4.0.0

* Small fixes
  • Loading branch information
Alex-Werner committed May 31, 2018
1 parent 30719fb commit d2ffd2a
Show file tree
Hide file tree
Showing 52 changed files with 3,535 additions and 4,493 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
sudo: false
language: node_js
sudo: false
node_js:
- '6'
- '8'
env:
- CXX=g++-4.8 CC=gcc-4.8
addons:
Expand All @@ -10,11 +13,8 @@ addons:
- g++-4.8
- gcc-4.8
- libzmq3-dev
node_js:
- "v0.10.25"

script:
- ./scripts/download
- npm run regtest
- npm run test
- npm run jshint
after_success:
Expand Down
71 changes: 67 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,48 @@ Dashcore Node

A Dash full node for building applications and services with Node.js. A node is extensible and can be configured to run additional services. At the minimum a node has an interface to [Dash Core (dashd) v0.12.1.x](https://github.com/dashpay/dash/tree/v0.12.1.x) for more advanced address queries. Additional services can be enabled to make a node more useful such as exposing new APIs, running a block explorer and wallet service.

## Install
## Usages

### As a standalone server

```bash
git clone https://github.com/dashevo/dashcore-node
cd dashcore-node
./bin/dashcore-node start
```

When running the start command, it will seek for a .dashcore folder with a dashcore-node.json conf file.
If it doesn't exist, it will create it, with basic task to connect to dashd.

Some plugins are available :

- Insight-API : `./bin/dashcore-node addservice @dashevo/insight-api
- Insight-UI : `./bin/dashcore-node addservice @dashevo/insight-ui`

You also might want to add these index to your dash.conf file :
```
-addressindex
-timestampindex
-spentindex
```

### As a library

```bash
npm install -g @dashevo/dashcore-node
npm install @dashevo/dashcore-node
```

```javascript
const dashcore = require('@dashevo/dashcore-node');
const config = require('./dashcore-node.json');

let node = dashcore.scaffold.start({ path: "", config: config });
node.on('ready', function() {
//Dash core started
dashd.on('tx', function(txData) {
let tx = new dashcore.lib.Transaction(txData);
});
});
```

## Prerequisites
Expand All @@ -31,7 +69,7 @@ dashcore-node start

This will create a directory with configuration files for your node and install the necessary dependencies.

Please note that [Dashs v0.12.1.x](https://github.com/dashpay/dash/tree/v0.12.1.x) will be downloaded automatically. Once completed the dashd binary should be placed into the &lt;dash-data-dir&gt; folder specified during node creation.
Please note that [Dash Core](https://github.com/dashpay/dash/tree/master) needs to be installed first.

For more information about (and developing) services, please see the [Service Documentation](docs/services.md).

Expand All @@ -47,13 +85,38 @@ There are several add-on services available to extend the functionality of Bitco

- [Upgrade Notes](docs/upgrade.md)
- [Services](docs/services.md)
- [Bitcoind](docs/services/bitcoind.md) - Interface to Bitcoin Core
- [Dashd](docs/services/dashd.md) - Interface to Dash Core
- [Web](docs/services/web.md) - Creates an express application over which services can expose their web/API content
- [Development Environment](docs/development.md) - Guide for setting up a development environment
- [Node](docs/node.md) - Details on the node constructor
- [Bus](docs/bus.md) - Overview of the event bus constructor
- [Release Process](docs/release.md) - Information about verifying a release and the release process.


## Setting up dev environment (with Insight)

Prerequisite : Having a dashd node already runing `dashd --daemon`.

Dashcore-node : `git clone https://github.com/dashevo/dashcore-node -b develop`
Insight-api (optional) : `git clone https://github.com/dashevo/insight-api -b develop`
Insight-UI (optional) : `git clone https://github.com/dashevo/insight-ui -b develop`

Install them :
```
cd dashcore-node && npm install \
&& cd ../insight-ui && npm install \
&& cd ../insight-api && npm install && cd ..
```

Symbolic linking in parent folder :
```
npm link ../insight-api
npm link ../insight-ui
```

Start with `./bin/dashcore-node start` to first generate a ~/.dashcore/dashcore-node.json file.
Append this file with `"@dashevo/insight-ui"` and `"@dashevo/insight-api"` in the services array.

## Contributing

Please send pull requests for bug fixes, code optimization, and ideas for improvement. For more information on how to contribute, please refer to our [CONTRIBUTING](https://github.com/dashevo/dashcore/blob/master/CONTRIBUTING.md) file.
Expand Down
48 changes: 24 additions & 24 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

var benchmark = require('benchmark');
var bitcoin = require('bitcoin');
var dashdRPC = require('@dashevo/dashd-rpc');
var async = require('async');
var maxTime = 20;

console.log('Bitcoin Service native interface vs. Bitcoin JSON RPC interface');
console.log('Dash Service native interface vs. Dash JSON RPC interface');
console.log('----------------------------------------------------------------------');

// To run the benchmarks a fully synced Bitcore Core directory is needed. The RPC comands
// can be modified to match the settings in bitcoin.conf.
// To run the benchmarks a fully synced Dash Core directory is needed. The RPC comands
// can be modified to match the settings in dash.conf.

var fixtureData = {
blockHashes: [
Expand All @@ -26,34 +26,34 @@ var fixtureData = {
]
};

var bitcoind = require('../').services.Bitcoin({
var dashd = require('../').services.Dash({
node: {
datadir: process.env.HOME + '/.bitcoin',
datadir: process.env.HOME + '/.dash',
network: {
name: 'testnet'
}
}
});

bitcoind.on('error', function(err) {
dashd.on('error', function(err) {
console.error(err.message);
});

bitcoind.start(function(err) {
dashd.start(function(err) {
if (err) {
throw err;
}
console.log('Bitcoin Core started');
console.log('Dash Core started');
});

bitcoind.on('ready', function() {
dashd.on('ready', function() {

console.log('Bitcoin Core ready');
console.log('Dash Core ready');

var client = new bitcoin.Client({
var client = new dashdRPC({
host: 'localhost',
port: 18332,
user: 'bitcoin',
user: 'dash',
pass: 'local321'
});

Expand All @@ -64,12 +64,12 @@ bitcoind.on('ready', function() {
var hashesLength = fixtureData.blockHashes.length;
var txLength = fixtureData.txHashes.length;

function bitcoindGetBlockNative(deffered) {
function dashdGetBlockNative(deffered) {
if (c >= hashesLength) {
c = 0;
}
var hash = fixtureData.blockHashes[c];
bitcoind.getBlock(hash, function(err, block) {
dashd.getBlock(hash, function(err, block) {
if (err) {
throw err;
}
Expand All @@ -78,7 +78,7 @@ bitcoind.on('ready', function() {
c++;
}

function bitcoindGetBlockJsonRpc(deffered) {
function dashdGetBlockJsonRpc(deffered) {
if (c >= hashesLength) {
c = 0;
}
Expand All @@ -92,12 +92,12 @@ bitcoind.on('ready', function() {
c++;
}

function bitcoinGetTransactionNative(deffered) {
function dashGetTransactionNative(deffered) {
if (c >= txLength) {
c = 0;
}
var hash = fixtureData.txHashes[c];
bitcoind.getTransaction(hash, true, function(err, tx) {
dashd.getTransaction(hash, true, function(err, tx) {
if (err) {
throw err;
}
Expand All @@ -106,7 +106,7 @@ bitcoind.on('ready', function() {
c++;
}

function bitcoinGetTransactionJsonRpc(deffered) {
function dashGetTransactionJsonRpc(deffered) {
if (c >= txLength) {
c = 0;
}
Expand All @@ -122,22 +122,22 @@ bitcoind.on('ready', function() {

var suite = new benchmark.Suite();

suite.add('bitcoind getblock (native)', bitcoindGetBlockNative, {
suite.add('dashd getblock (native)', dashdGetBlockNative, {
defer: true,
maxTime: maxTime
});

suite.add('bitcoind getblock (json rpc)', bitcoindGetBlockJsonRpc, {
suite.add('dashd getblock (json rpc)', dashdGetBlockJsonRpc, {
defer: true,
maxTime: maxTime
});

suite.add('bitcoind gettransaction (native)', bitcoinGetTransactionNative, {
suite.add('dashd gettransaction (native)', dashGetTransactionNative, {
defer: true,
maxTime: maxTime
});

suite.add('bitcoind gettransaction (json rpc)', bitcoinGetTransactionJsonRpc, {
suite.add('dashd gettransaction (json rpc)', dashGetTransactionJsonRpc, {
defer: true,
maxTime: maxTime
});
Expand All @@ -158,7 +158,7 @@ bitcoind.on('ready', function() {
throw err;
}
console.log('Finished');
bitcoind.stop(function(err) {
dashd.stop(function(err) {
if (err) {
console.error('Fail to stop services: ' + err);
process.exit(1);
Expand Down
4 changes: 0 additions & 4 deletions bin/bitcore-node-dash

This file was deleted.

4 changes: 4 additions & 0 deletions bin/dashcore-node
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

var dashcore = require('../lib/cli/dashcore');
dashcore();
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports.Service = require('./lib/service');
module.exports.errors = require('./lib/errors');

module.exports.services = {};
module.exports.services.Bitcoin = require('./lib/services/bitcoind');
module.exports.services.Dash = require('./lib/services/dashd');
module.exports.services.Web = require('./lib/services/web');

module.exports.scaffold = {};
Expand All @@ -21,7 +21,7 @@ module.exports.scaffold.defaultConfig = require('./lib/scaffold/default-config')
module.exports.cli = {};
module.exports.cli.main = require('./lib/cli/main');
module.exports.cli.daemon = require('./lib/cli/daemon');
module.exports.cli.bitcore = require('./lib/cli/bitcore');
module.exports.cli.bitcored = require('./lib/cli/bitcored');
module.exports.cli.dashcore = require('./lib/cli/dashcore');
module.exports.cli.dashcored = require('./lib/cli/dashcored');

module.exports.lib = require('bitcore-lib-dash');
module.exports.lib = require('@dashevo/dashcore-lib');
14 changes: 7 additions & 7 deletions lib/cli/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

var program = require('commander');
var path = require('path');
var bitcore = require('..');
var dashcore = require('..');

function main(servicesPath, additionalServices) {
/* jshint maxstatements: 100 */

var version = bitcore.version;
var start = bitcore.scaffold.start;
var findConfig = bitcore.scaffold.findConfig;
var defaultConfig = bitcore.scaffold.defaultConfig;
var version = dashcore.version;
var start = dashcore.scaffold.start;
var findConfig = dashcore.scaffold.findConfig;
var defaultConfig = dashcore.scaffold.defaultConfig;

program
.version(version)
.description('Start the current node')
.option('-c, --config <dir>', 'Specify the directory with Bitcore Node configuration')
.option('-d, --daemon', 'Make bitcore a daemon (running in the background)');
.option('-c, --config <dir>', 'Specify the directory with Dashcore Node configuration')
.option('-d, --daemon', 'Make dashcore a daemon (running in the background)');

program.parse(process.argv);

Expand Down
8 changes: 4 additions & 4 deletions lib/cli/bitcore.js → lib/cli/dashcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ var Liftoff = require('liftoff');
function main(parentServicesPath, additionalServices) {

var liftoff = new Liftoff({
name: 'bitcore',
moduleName: 'bitcore-node-dash',
configName: 'bitcore-node-dash',
processTitle: 'bitcore'
name: 'dashcore',
moduleName: 'dashcore-node',
configName: 'dashcore-node',
processTitle: 'dashcore'
}).on('require', function (name) {
console.log('Loading:', name);
}).on('requireFail', function (name, err) {
Expand Down
8 changes: 4 additions & 4 deletions lib/cli/bitcored.js → lib/cli/dashcored.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ var Liftoff = require('liftoff');
function main(parentServicesPath, additionalServices) {

var liftoff = new Liftoff({
name: 'bitcored',
moduleName: 'bitcore-node-dash',
configName: 'bitcore-node-dash',
processTitle: 'bitcored'
name: 'dashcored',
moduleName: 'dashcore-node',
configName: 'dashcore-node',
processTitle: 'dashcored'
}).on('require', function (name) {
console.log('Loading:', name);
}).on('requireFail', function (name, err) {
Expand Down
Loading

0 comments on commit d2ffd2a

Please sign in to comment.