Skip to content

Commit 6826bca

Browse files
committed
chore: 'npm run fmt' to apply style rules
1 parent 3f5931e commit 6826bca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5685
-5668
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Dashcore Node
2-
============
1+
# Dashcore Node
32

43
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.13.0](https://github.com/dashpay/dash/tree/v0.13.0.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.
54

@@ -23,6 +22,7 @@ Some plugins are available :
2322
- Insight-UI : `./bin/dashcore-node addservice @dashevo/insight-ui`
2423

2524
You also might want to add these index to your dash.conf file :
25+
2626
```
2727
-addressindex
2828
-timestampindex
@@ -36,25 +36,25 @@ npm install @dashevo/dashcore-node
3636
```
3737

3838
```javascript
39-
const dashcore = require('@dashevo/dashcore-node');
40-
const config = require('./dashcore-node.json');
39+
const dashcore = require("@dashevo/dashcore-node");
40+
const config = require("./dashcore-node.json");
4141

4242
let node = dashcore.scaffold.start({ path: "", config: config });
43-
node.on('ready', function () {
44-
console.log("Dash core started");
45-
46-
node.services.dashd.on('tx', function(txData) {
47-
let tx = new dashcore.lib.Transaction(txData);
48-
console.log(tx);
49-
});
43+
node.on("ready", function () {
44+
console.log("Dash core started");
45+
46+
node.services.dashd.on("tx", function (txData) {
47+
let tx = new dashcore.lib.Transaction(txData);
48+
console.log(tx);
49+
});
5050
});
5151
```
5252

5353
## Prerequisites
5454

55-
- Dash Core (dashd) (v0.13.0) with support for additional indexing *(see above)*
55+
- Dash Core (dashd) (v0.13.0) with support for additional indexing _(see above)_
5656
- Node.js v8+
57-
- ZeroMQ *(libzmq3-dev for Ubuntu/Debian or zeromq on OSX)*
57+
- ZeroMQ _(libzmq3-dev for Ubuntu/Debian or zeromq on OSX)_
5858
- ~50GB of disk storage
5959
- ~1GB of RAM
6060

@@ -95,7 +95,6 @@ There are several add-on services available to extend the functionality of Bitco
9595
- [Bus](docs/bus.md) - Overview of the event bus constructor
9696
- [Release Process](docs/release.md) - Information about verifying a release and the release process.
9797

98-
9998
## Setting up dev environment (with Insight)
10099

101100
Prerequisite : Having a dashd node already runing `dashd --daemon`.
@@ -105,13 +104,15 @@ Insight-api (optional) : `git clone https://github.com/dashevo/insight-api -b de
105104
Insight-UI (optional) : `git clone https://github.com/dashevo/insight-ui -b develop`
106105

107106
Install them :
107+
108108
```
109109
cd dashcore-node && npm install \
110110
&& cd ../insight-ui && npm install \
111111
&& cd ../insight-api && npm install && cd ..
112112
```
113113

114114
Symbolic linking in parent folder :
115+
115116
```
116117
npm link ../insight-api
117118
npm link ../insight-ui

benchmarks/index.js

Lines changed: 123 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,170 @@
1-
'use strict';
1+
"use strict";
22

3-
var benchmark = require('benchmark');
4-
var dashdRPC = require('@dashevo/dashd-rpc');
5-
var async = require('async');
3+
var benchmark = require("benchmark");
4+
var dashdRPC = require("@dashevo/dashd-rpc");
5+
var async = require("async");
66
var maxTime = 20;
77

8-
console.log('Dash Service native interface vs. Dash JSON RPC interface');
9-
console.log('----------------------------------------------------------------------');
8+
console.log("Dash Service native interface vs. Dash JSON RPC interface");
9+
console.log("----------------------------------------------------------------------");
1010

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

1414
var fixtureData = {
1515
blockHashes: [
16-
'00000000fa7a4acea40e5d0591d64faf48fd862fa3561d111d967fc3a6a94177',
17-
'000000000017e9e0afc4bc55339f60ffffb9cbe883f7348a9fbc198a486d5488',
18-
'000000000019ddb889b534c5d85fca2c91a73feef6fd775cd228dea45353bae1',
19-
'0000000000977ac3d9f5261efc88a3c2d25af92a91350750d00ad67744fa8d03'
16+
"00000000fa7a4acea40e5d0591d64faf48fd862fa3561d111d967fc3a6a94177",
17+
"000000000017e9e0afc4bc55339f60ffffb9cbe883f7348a9fbc198a486d5488",
18+
"000000000019ddb889b534c5d85fca2c91a73feef6fd775cd228dea45353bae1",
19+
"0000000000977ac3d9f5261efc88a3c2d25af92a91350750d00ad67744fa8d03",
2020
],
2121
txHashes: [
22-
'5523b432c1bd6c101bee704ad6c560fd09aefc483f8a4998df6741feaa74e6eb',
23-
'ff48393e7731507c789cfa9cbfae045b10e023ce34ace699a63cdad88c8b43f8',
24-
'5d35c5eebf704877badd0a131b0a86588041997d40dbee8ccff21ca5b7e5e333',
25-
'88842f2cf9d8659c3434f6bc0c515e22d87f33e864e504d2d7117163a572a3aa',
26-
]
22+
"5523b432c1bd6c101bee704ad6c560fd09aefc483f8a4998df6741feaa74e6eb",
23+
"ff48393e7731507c789cfa9cbfae045b10e023ce34ace699a63cdad88c8b43f8",
24+
"5d35c5eebf704877badd0a131b0a86588041997d40dbee8ccff21ca5b7e5e333",
25+
"88842f2cf9d8659c3434f6bc0c515e22d87f33e864e504d2d7117163a572a3aa",
26+
],
2727
};
2828

29-
var dashd = require('../').services.Dash({
29+
var dashd = require("../").services.Dash({
3030
node: {
31-
datadir: process.env.HOME + '/.dash',
31+
datadir: process.env.HOME + "/.dash",
3232
network: {
33-
name: 'testnet'
34-
}
35-
}
33+
name: "testnet",
34+
},
35+
},
3636
});
3737

38-
dashd.on('error', function(err) {
38+
dashd.on("error", function (err) {
3939
console.error(err.message);
4040
});
4141

42-
dashd.start(function(err) {
42+
dashd.start(function (err) {
4343
if (err) {
4444
throw err;
4545
}
46-
console.log('Dash Core started');
46+
console.log("Dash Core started");
4747
});
4848

49-
dashd.on('ready', function() {
50-
51-
console.log('Dash Core ready');
49+
dashd.on("ready", function () {
50+
console.log("Dash Core ready");
5251

5352
var client = new dashdRPC({
54-
host: 'localhost',
53+
host: "localhost",
5554
port: 18332,
56-
user: 'dash',
57-
pass: 'local321'
55+
user: "dash",
56+
pass: "local321",
5857
});
5958

60-
async.series([
61-
function(next) {
62-
63-
var c = 0;
64-
var hashesLength = fixtureData.blockHashes.length;
65-
var txLength = fixtureData.txHashes.length;
59+
async.series(
60+
[
61+
function (next) {
62+
var c = 0;
63+
var hashesLength = fixtureData.blockHashes.length;
64+
var txLength = fixtureData.txHashes.length;
6665

67-
function dashdGetBlockNative(deffered) {
68-
if (c >= hashesLength) {
69-
c = 0;
70-
}
71-
var hash = fixtureData.blockHashes[c];
72-
dashd.getBlock(hash, function(err, block) {
73-
if (err) {
74-
throw err;
66+
function dashdGetBlockNative(deffered) {
67+
if (c >= hashesLength) {
68+
c = 0;
7569
}
76-
deffered.resolve();
77-
});
78-
c++;
79-
}
80-
81-
function dashdGetBlockJsonRpc(deffered) {
82-
if (c >= hashesLength) {
83-
c = 0;
70+
var hash = fixtureData.blockHashes[c];
71+
dashd.getBlock(hash, function (err, block) {
72+
if (err) {
73+
throw err;
74+
}
75+
deffered.resolve();
76+
});
77+
c++;
8478
}
85-
var hash = fixtureData.blockHashes[c];
86-
client.getBlock(hash, false, function(err, block) {
87-
if (err) {
88-
throw err;
89-
}
90-
deffered.resolve();
91-
});
92-
c++;
93-
}
9479

95-
function dashGetTransactionNative(deffered) {
96-
if (c >= txLength) {
97-
c = 0;
98-
}
99-
var hash = fixtureData.txHashes[c];
100-
dashd.getTransaction(hash, true, function(err, tx) {
101-
if (err) {
102-
throw err;
80+
function dashdGetBlockJsonRpc(deffered) {
81+
if (c >= hashesLength) {
82+
c = 0;
10383
}
104-
deffered.resolve();
105-
});
106-
c++;
107-
}
84+
var hash = fixtureData.blockHashes[c];
85+
client.getBlock(hash, false, function (err, block) {
86+
if (err) {
87+
throw err;
88+
}
89+
deffered.resolve();
90+
});
91+
c++;
92+
}
10893

109-
function dashGetTransactionJsonRpc(deffered) {
110-
if (c >= txLength) {
111-
c = 0;
94+
function dashGetTransactionNative(deffered) {
95+
if (c >= txLength) {
96+
c = 0;
97+
}
98+
var hash = fixtureData.txHashes[c];
99+
dashd.getTransaction(hash, true, function (err, tx) {
100+
if (err) {
101+
throw err;
102+
}
103+
deffered.resolve();
104+
});
105+
c++;
112106
}
113-
var hash = fixtureData.txHashes[c];
114-
client.getRawTransaction(hash, function(err, tx) {
115-
if (err) {
116-
throw err;
107+
108+
function dashGetTransactionJsonRpc(deffered) {
109+
if (c >= txLength) {
110+
c = 0;
117111
}
118-
deffered.resolve();
119-
});
120-
c++;
121-
}
112+
var hash = fixtureData.txHashes[c];
113+
client.getRawTransaction(hash, function (err, tx) {
114+
if (err) {
115+
throw err;
116+
}
117+
deffered.resolve();
118+
});
119+
c++;
120+
}
122121

123-
var suite = new benchmark.Suite();
122+
var suite = new benchmark.Suite();
124123

125-
suite.add('dashd getblock (native)', dashdGetBlockNative, {
126-
defer: true,
127-
maxTime: maxTime
128-
});
124+
suite.add("dashd getblock (native)", dashdGetBlockNative, {
125+
defer: true,
126+
maxTime: maxTime,
127+
});
129128

130-
suite.add('dashd getblock (json rpc)', dashdGetBlockJsonRpc, {
131-
defer: true,
132-
maxTime: maxTime
133-
});
129+
suite.add("dashd getblock (json rpc)", dashdGetBlockJsonRpc, {
130+
defer: true,
131+
maxTime: maxTime,
132+
});
134133

135-
suite.add('dashd gettransaction (native)', dashGetTransactionNative, {
136-
defer: true,
137-
maxTime: maxTime
138-
});
134+
suite.add("dashd gettransaction (native)", dashGetTransactionNative, {
135+
defer: true,
136+
maxTime: maxTime,
137+
});
139138

140-
suite.add('dashd gettransaction (json rpc)', dashGetTransactionJsonRpc, {
141-
defer: true,
142-
maxTime: maxTime
143-
});
139+
suite.add("dashd gettransaction (json rpc)", dashGetTransactionJsonRpc, {
140+
defer: true,
141+
maxTime: maxTime,
142+
});
144143

145-
suite
146-
.on('cycle', function(event) {
147-
console.log(String(event.target));
148-
})
149-
.on('complete', function() {
150-
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
151-
console.log('----------------------------------------------------------------------');
152-
next();
153-
})
154-
.run();
155-
}
156-
], function(err) {
157-
if (err) {
158-
throw err;
159-
}
160-
console.log('Finished');
161-
dashd.stop(function(err) {
144+
suite
145+
.on("cycle", function (event) {
146+
console.log(String(event.target));
147+
})
148+
.on("complete", function () {
149+
console.log("Fastest is " + this.filter("fastest").pluck("name"));
150+
console.log("----------------------------------------------------------------------");
151+
next();
152+
})
153+
.run();
154+
},
155+
],
156+
function (err) {
162157
if (err) {
163-
console.error('Fail to stop services: ' + err);
164-
process.exit(1);
158+
throw err;
165159
}
166-
process.exit(0);
167-
});
168-
});
160+
console.log("Finished");
161+
dashd.stop(function (err) {
162+
if (err) {
163+
console.error("Fail to stop services: " + err);
164+
process.exit(1);
165+
}
166+
process.exit(0);
167+
});
168+
}
169+
);
169170
});

docs/bus.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Bus
2+
23
The bus provides a way to subscribe to events from any of the services running. It's implemented abstract from transport specific implementation. The primary use of the bus in Bitcore Node is for subscribing to events via a web socket.
34

45
## Opening/Closing
56

67
```javascript
7-
88
// a node is needed to be able to open a bus
99
var node = new Node(configuration);
1010

@@ -18,13 +18,12 @@ bus.close();
1818
## Subscribing/Unsubscribing
1919

2020
```javascript
21-
2221
// subscribe to all transaction events
23-
bus.subscribe('bitcoind/rawtransaction');
22+
bus.subscribe("bitcoind/rawtransaction");
2423

2524
// to subscribe to new block hashes
26-
bus.subscribe('bitcoind/hashblock');
25+
bus.subscribe("bitcoind/hashblock");
2726

2827
// unsubscribe
29-
bus.unsubscribe('bitcoind/rawtransaction');
28+
bus.unsubscribe("bitcoind/rawtransaction");
3029
```

0 commit comments

Comments
 (0)