Skip to content

Commit ab2f5f8

Browse files
committed
Merge PR #921 from 'nodech/cleanup-class-members'
2 parents 77e22da + f24fb51 commit ab2f5f8

File tree

8 files changed

+27
-39
lines changed

8 files changed

+27
-39
lines changed

lib/client/node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
// Don't introduce any unnecessary dependencies to this.
1111

1212
const assert = require('bsert');
13-
const {Client} = require('bcurl');
13+
const bcurl = require('bcurl');
1414

1515
/**
1616
* Node Client
1717
* @alias module:client.NodeClient
1818
* @extends {bcurl.Client}
1919
*/
2020

21-
class NodeClient extends Client {
21+
class NodeClient extends bcurl.Client {
2222
/**
2323
* Creat a node client.
2424
* @param {Object?} options

lib/client/wallet.js

+13-17
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212
const assert = require('bsert');
1313
const EventEmitter = require('events');
14-
const {Client} = require('bcurl');
14+
const bcurl = require('bcurl');
1515

1616
/**
1717
* Wallet Client
1818
* @alias module:client.WalletClient
1919
* @extends {bcurl.Client}
2020
*/
2121

22-
class WalletClient extends Client {
22+
class WalletClient extends bcurl.Client {
2323
/**
2424
* Create a wallet client.
2525
* @param {Object?} options
@@ -32,8 +32,6 @@ class WalletClient extends Client {
3232

3333
/**
3434
* Open the client.
35-
* @private
36-
* @returns {Promise}
3735
*/
3836

3937
init() {
@@ -878,29 +876,27 @@ class WalletClient extends Client {
878876
*/
879877

880878
class Wallet extends EventEmitter {
881-
/** @type {WalletClient} */
882-
client;
883-
884-
/** @type {WalletClient} */
885-
parent;
886-
887-
/** @type {String} */
888-
id;
889-
890-
/** @type {String} */
891-
token;
892-
893879
/**
894880
* Create a wallet client.
895-
* @param {Object?} options
881+
* @param {WalletClient} parent
882+
* @param {String} id
883+
* @param {String} [token]
896884
*/
897885

898886
constructor(parent, id, token) {
899887
super();
888+
889+
/** @type {WalletClient} */
900890
this.parent = parent;
891+
892+
/** @type {WalletClient} */
901893
this.client = parent.clone();
902894
this.client.token = token;
895+
896+
/** @type {String} */
903897
this.id = id;
898+
899+
/** @type {String} */
904900
this.token = token;
905901
}
906902

lib/wallet/nodeclient.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ const AsyncEmitter = require('bevent');
1818
*/
1919

2020
class NodeClient extends AsyncEmitter {
21-
/** @type {Node} */
22-
node;
23-
2421
/**
2522
* Create a node client.
2623
* @constructor
@@ -30,6 +27,7 @@ class NodeClient extends AsyncEmitter {
3027
constructor(node) {
3128
super();
3229

30+
/** @type {Node} */
3331
this.node = node;
3432
this.network = node.network;
3533
this.filter = null;
@@ -78,7 +76,7 @@ class NodeClient extends AsyncEmitter {
7876
* @returns {Promise}
7977
*/
8078

81-
async open(options) {
79+
async open() {
8280
assert(!this.opened, 'NodeClient is already open.');
8381
this.opened = true;
8482
setImmediate(() => this.emit('connect'));

lib/wallet/nullclient.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class NullClient extends EventEmitter {
3636
* @returns {Promise}
3737
*/
3838

39-
async open(options) {
39+
async open() {
4040
assert(!this.opened, 'NullClient is already open.');
4141
this.opened = true;
4242
setImmediate(() => this.emit('connect'));

lib/wallet/txdb.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ const UNCONFIRMED_HEIGHT = 0xffffffff;
5858
*/
5959

6060
class TXDB {
61-
/** @type {WalletDB} */
62-
wdb;
63-
6461
/**
6562
* Create a TXDB.
6663
* @constructor
@@ -69,6 +66,7 @@ class TXDB {
6966
*/
7067

7168
constructor(wdb, wid) {
69+
/** @type {WalletDB} */
7270
this.wdb = wdb;
7371
this.db = wdb.db;
7472
this.logger = wdb.logger;

lib/wallet/walletdb.js

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const {scanActions} = require('../blockchain/common');
4444
/** @typedef {import('./records').BlockMeta} BlockMeta */
4545
/** @typedef {import('./txdb').BlockExtraInfo} BlockExtraInfo */
4646
/** @typedef {import('./walletkey')} WalletKey */
47+
/** @typedef {import('./nodeclient')} NodeClient */
48+
/** @typedef {import('./client')} NodeHTTPClient */
4749

4850
const {
4951
ChainState,
@@ -84,6 +86,7 @@ class WalletDB extends EventEmitter {
8486
this.network = this.options.network;
8587
this.logger = this.options.logger.context('wallet');
8688
this.workers = this.options.workers;
89+
/** @type {NullClient|NodeClient|NodeHTTPClient} */
8790
this.client = this.options.client || new NullClient(this);
8891
this.feeRate = this.options.feeRate;
8992
/** @type {bdb.DB} */

test/util/node-context.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ const {NodeClient, WalletClient} = require('../../lib/client');
1212
const Logger = require('blgr');
1313

1414
class NodeContext {
15-
/** @type {FullNode|SPVNode} */
16-
node;
17-
18-
/** @type {WalletClient} */
19-
wclient;
20-
21-
/** @type {NodeClient} */
22-
nclient;
23-
2415
constructor(options = {}) {
2516
this.name = 'node-test';
2617
this.options = {};
@@ -33,9 +24,13 @@ class NodeContext {
3324
});
3425

3526
this.initted = false;
27+
/** @type {FullNode|SPVNode|null} */
3628
this.node = null;
29+
/** @type {WalletNode|null} */
3730
this.walletNode = null;
31+
/** @type {NodeClient|null} */
3832
this.nclient = null;
33+
/** @type {WalletClient|null} */
3934
this.wclient = null;
4035

4136
this.clients = [];

test/util/nodes-context.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ const Network = require('../../lib/protocol/network');
55
const NodeContext = require('./node-context');
66

77
class NodesContext {
8-
/** @type {NodeContext[]} */
9-
nodeCtxs;
10-
118
constructor(network, size = 1) {
129
this.network = Network.get(network);
1310
this.size = size;
11+
/** @type {NodeContext[]} */
1412
this.nodeCtxs = [];
1513

1614
assert(this.size > 0);

0 commit comments

Comments
 (0)