Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/client/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
// Don't introduce any unnecessary dependencies to this.

const assert = require('bsert');
const {Client} = require('bcurl');
const bcurl = require('bcurl');

/**
* Node Client
* @alias module:client.NodeClient
* @extends {bcurl.Client}
*/

class NodeClient extends Client {
class NodeClient extends bcurl.Client {
/**
* Creat a node client.
* @param {Object?} options
Expand Down
30 changes: 13 additions & 17 deletions lib/client/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

const assert = require('bsert');
const EventEmitter = require('events');
const {Client} = require('bcurl');
const bcurl = require('bcurl');

/**
* Wallet Client
* @alias module:client.WalletClient
* @extends {bcurl.Client}
*/

class WalletClient extends Client {
class WalletClient extends bcurl.Client {
/**
* Create a wallet client.
* @param {Object?} options
Expand All @@ -32,8 +32,6 @@ class WalletClient extends Client {

/**
* Open the client.
* @private
* @returns {Promise}
*/

init() {
Expand Down Expand Up @@ -878,29 +876,27 @@ class WalletClient extends Client {
*/

class Wallet extends EventEmitter {
/** @type {WalletClient} */
client;

/** @type {WalletClient} */
parent;

/** @type {String} */
id;

/** @type {String} */
token;

/**
* Create a wallet client.
* @param {Object?} options
* @param {WalletClient} parent
* @param {String} id
* @param {String} [token]
*/

constructor(parent, id, token) {
super();

/** @type {WalletClient} */
this.parent = parent;

/** @type {WalletClient} */
this.client = parent.clone();
this.client.token = token;

/** @type {String} */
this.id = id;

/** @type {String} */
this.token = token;
}

Expand Down
6 changes: 2 additions & 4 deletions lib/wallet/nodeclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ const AsyncEmitter = require('bevent');
*/

class NodeClient extends AsyncEmitter {
/** @type {Node} */
node;

/**
* Create a node client.
* @constructor
Expand All @@ -30,6 +27,7 @@ class NodeClient extends AsyncEmitter {
constructor(node) {
super();

/** @type {Node} */
this.node = node;
this.network = node.network;
this.filter = null;
Expand Down Expand Up @@ -78,7 +76,7 @@ class NodeClient extends AsyncEmitter {
* @returns {Promise}
*/

async open(options) {
async open() {
assert(!this.opened, 'NodeClient is already open.');
this.opened = true;
setImmediate(() => this.emit('connect'));
Expand Down
2 changes: 1 addition & 1 deletion lib/wallet/nullclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NullClient extends EventEmitter {
* @returns {Promise}
*/

async open(options) {
async open() {
assert(!this.opened, 'NullClient is already open.');
this.opened = true;
setImmediate(() => this.emit('connect'));
Expand Down
4 changes: 1 addition & 3 deletions lib/wallet/txdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ const UNCONFIRMED_HEIGHT = 0xffffffff;
*/

class TXDB {
/** @type {WalletDB} */
wdb;

/**
* Create a TXDB.
* @constructor
Expand All @@ -69,6 +66,7 @@ class TXDB {
*/

constructor(wdb, wid) {
/** @type {WalletDB} */
this.wdb = wdb;
this.db = wdb.db;
this.logger = wdb.logger;
Expand Down
3 changes: 3 additions & 0 deletions lib/wallet/walletdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const {scanActions} = require('../blockchain/common');
/** @typedef {import('./records').BlockMeta} BlockMeta */
/** @typedef {import('./txdb').BlockExtraInfo} BlockExtraInfo */
/** @typedef {import('./walletkey')} WalletKey */
/** @typedef {import('./nodeclient')} NodeClient */
/** @typedef {import('./client')} NodeHTTPClient */

const {
ChainState,
Expand Down Expand Up @@ -84,6 +86,7 @@ class WalletDB extends EventEmitter {
this.network = this.options.network;
this.logger = this.options.logger.context('wallet');
this.workers = this.options.workers;
/** @type {NullClient|NodeClient|NodeHTTPClient} */
this.client = this.options.client || new NullClient(this);
this.feeRate = this.options.feeRate;
/** @type {bdb.DB} */
Expand Down
13 changes: 4 additions & 9 deletions test/util/node-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ const {NodeClient, WalletClient} = require('../../lib/client');
const Logger = require('blgr');

class NodeContext {
/** @type {FullNode|SPVNode} */
node;

/** @type {WalletClient} */
wclient;

/** @type {NodeClient} */
nclient;

constructor(options = {}) {
this.name = 'node-test';
this.options = {};
Expand All @@ -33,9 +24,13 @@ class NodeContext {
});

this.initted = false;
/** @type {FullNode|SPVNode|null} */
this.node = null;
/** @type {WalletNode|null} */
this.walletNode = null;
/** @type {NodeClient|null} */
this.nclient = null;
/** @type {WalletClient|null} */
this.wclient = null;

this.clients = [];
Expand Down
4 changes: 1 addition & 3 deletions test/util/nodes-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ const Network = require('../../lib/protocol/network');
const NodeContext = require('./node-context');

class NodesContext {
/** @type {NodeContext[]} */
nodeCtxs;

constructor(network, size = 1) {
this.network = Network.get(network);
this.size = size;
/** @type {NodeContext[]} */
this.nodeCtxs = [];

assert(this.size > 0);
Expand Down
Loading