util: remove util.inherits. inline inheritance.

This commit is contained in:
Christopher Jeffrey 2017-08-06 19:44:57 -07:00
parent 4ce070fad4
commit 62152a1005
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
54 changed files with 117 additions and 151 deletions

View File

@ -39,7 +39,7 @@ function WSProxy(options) {
this.init();
}
util.inherits(WSProxy, EventEmitter);
Object.setPrototypeOf(WSProxy.prototype, EventEmitter.prototype);
WSProxy.prototype.init = function init() {
this.io.on('error', (err) => {

View File

@ -86,7 +86,7 @@ function Chain(options) {
this.db = new ChainDB(this);
}
util.inherits(Chain, AsyncObject);
Object.setPrototypeOf(Chain.prototype, AsyncObject.prototype);
/**
* Open the chain, wait for the database to load.

View File

@ -50,7 +50,7 @@ function HTTPBase(options) {
this._init();
}
util.inherits(HTTPBase, AsyncObject);
Object.setPrototypeOf(HTTPBase.prototype, AsyncObject.prototype);
/**
* Initialize server.
@ -1218,7 +1218,7 @@ function Request(req, res, url) {
this.init(req, res, url);
}
util.inherits(Request, EventEmitter);
Object.setPrototypeOf(Request.prototype, EventEmitter.prototype);
Request.prototype.init = function init(req, res, url) {
assert(req);
@ -1369,7 +1369,7 @@ function Response(req, res) {
this.init(req, res);
}
util.inherits(Response, EventEmitter);
Object.setPrototypeOf(Response.prototype, EventEmitter.prototype);
Response.prototype.init = function init(req, res) {
assert(req);
@ -1535,7 +1535,7 @@ function WebSocket(socket, ctx) {
this.init();
}
util.inherits(WebSocket, EventEmitter);
Object.setPrototypeOf(WebSocket.prototype, EventEmitter.prototype);
WebSocket.prototype.init = function init() {
const socket = this.socket;

View File

@ -10,7 +10,6 @@
const Network = require('../protocol/network');
const AsyncObject = require('../utils/asyncobject');
const RPCClient = require('./rpcclient');
const util = require('../utils/util');
const request = require('./request');
/**
@ -43,7 +42,7 @@ function HTTPClient(options) {
this.rpc = new RPCClient(options);
}
util.inherits(HTTPClient, AsyncObject);
Object.setPrototypeOf(HTTPClient.prototype, AsyncObject.prototype);
/**
* Open the client, wait for socket to connect.

View File

@ -75,7 +75,7 @@ function RPC(node) {
this.init();
}
util.inherits(RPC, RPCBase);
Object.setPrototypeOf(RPC.prototype, RPCBase.prototype);
RPC.prototype.init = function init() {
this.add('stop', this.stop);

View File

@ -8,7 +8,6 @@
const assert = require('assert');
const EventEmitter = require('events');
const util = require('../utils/util');
const Lock = require('../utils/lock');
const Logger = require('../node/logger');
@ -30,7 +29,7 @@ function RPCBase() {
this.locker = new Lock();
}
util.inherits(RPCBase, EventEmitter);
Object.setPrototypeOf(RPCBase.prototype, EventEmitter.prototype);
/**
* RPC errors.
@ -312,7 +311,7 @@ function RPCError(code, msg) {
Error.captureStackTrace(this, RPCError);
}
util.inherits(RPCError, Error);
Object.setPrototypeOf(RPCError.prototype, Error.prototype);
/*
* Expose

View File

@ -8,7 +8,6 @@
const Network = require('../protocol/network');
const request = require('./request');
const util = require('../utils/util');
/**
* Bcoin RPC client.
@ -93,7 +92,7 @@ function RPCError(msg, code) {
Error.captureStackTrace(this, RPCError);
}
util.inherits(RPCError, Error);
Object.setPrototypeOf(RPCError.prototype, Error.prototype);
/*
* Expose

View File

@ -55,7 +55,7 @@ function HTTPServer(options) {
this.init();
}
util.inherits(HTTPServer, HTTPBase);
Object.setPrototypeOf(HTTPServer.prototype, HTTPBase.prototype);
/**
* Initialize routes.

View File

@ -10,7 +10,6 @@
const assert = require('assert');
const EventEmitter = require('events');
const Network = require('../protocol/network');
const util = require('../utils/util');
const Client = require('./client');
/**
@ -53,7 +52,7 @@ function HTTPWallet(options) {
this._init();
}
util.inherits(HTTPWallet, EventEmitter);
Object.setPrototypeOf(HTTPWallet.prototype, EventEmitter.prototype);
/**
* Initialize the wallet.

View File

@ -95,7 +95,7 @@ function Mempool(options) {
this.txIndex = new TXIndex();
}
util.inherits(Mempool, AsyncObject);
Object.setPrototypeOf(Mempool.prototype, AsyncObject.prototype);
/**
* Open the chain, wait for the database to load.

View File

@ -44,7 +44,7 @@ function CPUMiner(miner) {
this._init();
}
util.inherits(CPUMiner, AsyncObject);
Object.setPrototypeOf(CPUMiner.prototype, AsyncObject.prototype);
/**
* Nonce range interval.

View File

@ -46,7 +46,7 @@ function Miner(options) {
this.init();
}
util.inherits(Miner, AsyncObject);
Object.setPrototypeOf(Miner.prototype, AsyncObject.prototype);
/**
* Open the miner, wait for the chain and mempool to load.

View File

@ -11,7 +11,6 @@
const assert = require('assert');
const path = require('path');
const EventEmitter = require('events');
const util = require('../utils/util');
const co = require('../utils/co');
const digest = require('../crypto/digest');
const random = require('../crypto/random');
@ -87,7 +86,7 @@ function BIP150(bip151, host, outbound, db, key) {
this._init();
}
util.inherits(BIP150, EventEmitter);
Object.setPrototypeOf(BIP150.prototype, EventEmitter.prototype);
/**
* Initialize BIP150.

View File

@ -329,7 +329,7 @@ function BIP151(cipher) {
this.bip150 = null;
}
util.inherits(BIP151, EventEmitter);
Object.setPrototypeOf(BIP151.prototype, EventEmitter.prototype);
/**
* Cipher list.

View File

@ -59,7 +59,7 @@ function CompactBlock(options) {
this.fromOptions(options);
}
util.inherits(CompactBlock, AbstractBlock);
Object.setPrototypeOf(CompactBlock.prototype, AbstractBlock.prototype);
/**
* Inject properties from options object.

View File

@ -180,7 +180,7 @@ function VersionPacket(options) {
this.fromOptions(options);
}
util.inherits(VersionPacket, Packet);
Object.setPrototypeOf(VersionPacket.prototype, Packet.prototype);
VersionPacket.prototype.cmd = 'version';
VersionPacket.prototype.type = exports.types.VERSION;
@ -366,7 +366,7 @@ function VerackPacket() {
Packet.call(this);
}
util.inherits(VerackPacket, Packet);
Object.setPrototypeOf(VerackPacket.prototype, Packet.prototype);
VerackPacket.prototype.cmd = 'verack';
VerackPacket.prototype.type = exports.types.VERACK;
@ -410,7 +410,7 @@ function PingPacket(nonce) {
this.nonce = nonce || null;
}
util.inherits(PingPacket, Packet);
Object.setPrototypeOf(PingPacket.prototype, Packet.prototype);
PingPacket.prototype.cmd = 'ping';
PingPacket.prototype.type = exports.types.PING;
@ -506,7 +506,7 @@ function PongPacket(nonce) {
this.nonce = nonce || encoding.ZERO_U64;
}
util.inherits(PongPacket, Packet);
Object.setPrototypeOf(PongPacket.prototype, Packet.prototype);
PongPacket.prototype.cmd = 'pong';
PongPacket.prototype.type = exports.types.PONG;
@ -595,7 +595,7 @@ function GetAddrPacket() {
Packet.call(this);
}
util.inherits(GetAddrPacket, Packet);
Object.setPrototypeOf(GetAddrPacket.prototype, Packet.prototype);
GetAddrPacket.prototype.cmd = 'getaddr';
GetAddrPacket.prototype.type = exports.types.GETADDR;
@ -639,7 +639,7 @@ function AddrPacket(items) {
this.items = items || [];
}
util.inherits(AddrPacket, Packet);
Object.setPrototypeOf(AddrPacket.prototype, Packet.prototype);
AddrPacket.prototype.cmd = 'addr';
AddrPacket.prototype.type = exports.types.ADDR;
@ -735,7 +735,7 @@ function InvPacket(items) {
this.items = items || [];
}
util.inherits(InvPacket, Packet);
Object.setPrototypeOf(InvPacket.prototype, Packet.prototype);
InvPacket.prototype.cmd = 'inv';
InvPacket.prototype.type = exports.types.INV;
@ -842,7 +842,7 @@ function GetDataPacket(items) {
InvPacket.call(this, items);
}
util.inherits(GetDataPacket, InvPacket);
Object.setPrototypeOf(GetDataPacket.prototype, InvPacket.prototype);
GetDataPacket.prototype.cmd = 'getdata';
GetDataPacket.prototype.type = exports.types.GETDATA;
@ -884,7 +884,7 @@ function NotFoundPacket(items) {
InvPacket.call(this, items);
}
util.inherits(NotFoundPacket, InvPacket);
Object.setPrototypeOf(NotFoundPacket.prototype, InvPacket.prototype);
NotFoundPacket.prototype.cmd = 'notfound';
NotFoundPacket.prototype.type = exports.types.NOTFOUND;
@ -932,7 +932,7 @@ function GetBlocksPacket(locator, stop) {
this.stop = stop || null;
}
util.inherits(GetBlocksPacket, Packet);
Object.setPrototypeOf(GetBlocksPacket.prototype, Packet.prototype);
GetBlocksPacket.prototype.cmd = 'getblocks';
GetBlocksPacket.prototype.type = exports.types.GETBLOCKS;
@ -1042,7 +1042,7 @@ function GetHeadersPacket(locator, stop) {
GetBlocksPacket.call(this, locator, stop);
}
util.inherits(GetHeadersPacket, GetBlocksPacket);
Object.setPrototypeOf(GetHeadersPacket.prototype, GetBlocksPacket.prototype);
GetHeadersPacket.prototype.cmd = 'getheaders';
GetHeadersPacket.prototype.type = exports.types.GETHEADERS;
@ -1086,7 +1086,7 @@ function HeadersPacket(items) {
this.items = items || [];
}
util.inherits(HeadersPacket, Packet);
Object.setPrototypeOf(HeadersPacket.prototype, Packet.prototype);
HeadersPacket.prototype.cmd = 'headers';
HeadersPacket.prototype.type = exports.types.HEADERS;
@ -1185,7 +1185,7 @@ function SendHeadersPacket() {
Packet.call(this);
}
util.inherits(SendHeadersPacket, Packet);
Object.setPrototypeOf(SendHeadersPacket.prototype, Packet.prototype);
SendHeadersPacket.prototype.cmd = 'sendheaders';
SendHeadersPacket.prototype.type = exports.types.SENDHEADERS;
@ -1232,7 +1232,7 @@ function BlockPacket(block, witness) {
this.witness = witness || false;
}
util.inherits(BlockPacket, Packet);
Object.setPrototypeOf(BlockPacket.prototype, Packet.prototype);
BlockPacket.prototype.cmd = 'block';
BlockPacket.prototype.type = exports.types.BLOCK;
@ -1334,7 +1334,7 @@ function TXPacket(tx, witness) {
this.witness = witness || false;
}
util.inherits(TXPacket, Packet);
Object.setPrototypeOf(TXPacket.prototype, Packet.prototype);
TXPacket.prototype.cmd = 'tx';
TXPacket.prototype.type = exports.types.TX;
@ -1442,7 +1442,7 @@ function RejectPacket(options) {
this.fromOptions(options);
}
util.inherits(RejectPacket, Packet);
Object.setPrototypeOf(RejectPacket.prototype, Packet.prototype);
/**
* Reject codes. Note that `internal` and higher
@ -1729,7 +1729,7 @@ function MempoolPacket() {
Packet.call(this);
}
util.inherits(MempoolPacket, Packet);
Object.setPrototypeOf(MempoolPacket.prototype, Packet.prototype);
MempoolPacket.prototype.cmd = 'mempool';
MempoolPacket.prototype.type = exports.types.MEMPOOL;
@ -1772,7 +1772,7 @@ function FilterLoadPacket(filter) {
this.filter = filter || new Bloom();
}
util.inherits(FilterLoadPacket, Packet);
Object.setPrototypeOf(FilterLoadPacket.prototype, Packet.prototype);
FilterLoadPacket.prototype.cmd = 'filterload';
FilterLoadPacket.prototype.type = exports.types.FILTERLOAD;
@ -1874,7 +1874,7 @@ function FilterAddPacket(data) {
this.data = data || DUMMY;
}
util.inherits(FilterAddPacket, Packet);
Object.setPrototypeOf(FilterAddPacket.prototype, Packet.prototype);
FilterAddPacket.prototype.cmd = 'filteradd';
FilterAddPacket.prototype.type = exports.types.FILTERADD;
@ -1954,7 +1954,7 @@ function FilterClearPacket() {
Packet.call(this);
}
util.inherits(FilterClearPacket, Packet);
Object.setPrototypeOf(FilterClearPacket.prototype, Packet.prototype);
FilterClearPacket.prototype.cmd = 'filterclear';
FilterClearPacket.prototype.type = exports.types.FILTERCLEAR;
@ -1988,7 +1988,7 @@ function MerkleBlockPacket(block) {
this.block = block || new MerkleBlock();
}
util.inherits(MerkleBlockPacket, Packet);
Object.setPrototypeOf(MerkleBlockPacket.prototype, Packet.prototype);
MerkleBlockPacket.prototype.cmd = 'merkleblock';
MerkleBlockPacket.prototype.type = exports.types.MERKLEBLOCK;
@ -2071,7 +2071,7 @@ function FeeFilterPacket(rate) {
this.rate = rate || 0;
}
util.inherits(FeeFilterPacket, Packet);
Object.setPrototypeOf(FeeFilterPacket.prototype, Packet.prototype);
FeeFilterPacket.prototype.cmd = 'feefilter';
FeeFilterPacket.prototype.type = exports.types.FEEFILTER;
@ -2167,7 +2167,7 @@ function SendCmpctPacket(mode, version) {
this.version = version || 1;
}
util.inherits(SendCmpctPacket, Packet);
Object.setPrototypeOf(SendCmpctPacket.prototype, Packet.prototype);
SendCmpctPacket.prototype.cmd = 'sendcmpct';
SendCmpctPacket.prototype.type = exports.types.SENDCMPCT;
@ -2275,7 +2275,7 @@ function CmpctBlockPacket(block, witness) {
this.witness = witness || false;
}
util.inherits(CmpctBlockPacket, Packet);
Object.setPrototypeOf(CmpctBlockPacket.prototype, Packet.prototype);
CmpctBlockPacket.prototype.cmd = 'cmpctblock';
CmpctBlockPacket.prototype.type = exports.types.CMPCTBLOCK;
@ -2374,7 +2374,7 @@ function GetBlockTxnPacket(request) {
this.request = request || new bip152.TXRequest();
}
util.inherits(GetBlockTxnPacket, Packet);
Object.setPrototypeOf(GetBlockTxnPacket.prototype, Packet.prototype);
GetBlockTxnPacket.prototype.cmd = 'getblocktxn';
GetBlockTxnPacket.prototype.type = exports.types.GETBLOCKTXN;
@ -2470,7 +2470,7 @@ function BlockTxnPacket(response, witness) {
this.witness = witness || false;
}
util.inherits(BlockTxnPacket, Packet);
Object.setPrototypeOf(BlockTxnPacket.prototype, Packet.prototype);
BlockTxnPacket.prototype.cmd = 'blocktxn';
BlockTxnPacket.prototype.type = exports.types.BLOCKTXN;
@ -2572,7 +2572,7 @@ function EncinitPacket(publicKey, cipher) {
this.cipher = cipher || 0;
}
util.inherits(EncinitPacket, Packet);
Object.setPrototypeOf(EncinitPacket.prototype, Packet.prototype);
EncinitPacket.prototype.cmd = 'encinit';
EncinitPacket.prototype.type = exports.types.ENCINIT;
@ -2667,7 +2667,7 @@ function EncackPacket(publicKey) {
this.publicKey = publicKey || encoding.ZERO_KEY;
}
util.inherits(EncackPacket, Packet);
Object.setPrototypeOf(EncackPacket.prototype, Packet.prototype);
EncackPacket.prototype.cmd = 'encack';
EncackPacket.prototype.type = exports.types.ENCACK;
@ -2760,7 +2760,7 @@ function AuthChallengePacket(hash) {
this.hash = hash || encoding.ZERO_HASH;
}
util.inherits(AuthChallengePacket, Packet);
Object.setPrototypeOf(AuthChallengePacket.prototype, Packet.prototype);
AuthChallengePacket.prototype.cmd = 'authchallenge';
AuthChallengePacket.prototype.type = exports.types.AUTHCHALLENGE;
@ -2853,7 +2853,7 @@ function AuthReplyPacket(signature) {
this.signature = signature || encoding.ZERO_SIG64;
}
util.inherits(AuthReplyPacket, Packet);
Object.setPrototypeOf(AuthReplyPacket.prototype, Packet.prototype);
AuthReplyPacket.prototype.cmd = 'authreply';
AuthReplyPacket.prototype.type = exports.types.AUTHREPLY;
@ -2946,7 +2946,7 @@ function AuthProposePacket(hash) {
this.hash = hash || encoding.ZERO_HASH;
}
util.inherits(AuthProposePacket, Packet);
Object.setPrototypeOf(AuthProposePacket.prototype, Packet.prototype);
AuthProposePacket.prototype.cmd = 'authpropose';
AuthProposePacket.prototype.type = exports.types.AUTHPROPOSE;
@ -3042,7 +3042,7 @@ function UnknownPacket(cmd, data) {
this.data = data;
}
util.inherits(UnknownPacket, Packet);
Object.setPrototypeOf(UnknownPacket.prototype, Packet.prototype);
UnknownPacket.prototype.type = exports.types.UNKNOWN;

View File

@ -40,7 +40,7 @@ function Parser(network) {
this.header = null;
}
util.inherits(Parser, EventEmitter);
Object.setPrototypeOf(Parser.prototype, EventEmitter.prototype);
/**
* Emit an error.

View File

@ -146,7 +146,7 @@ function Peer(options) {
this._init();
}
util.inherits(Peer, EventEmitter);
Object.setPrototypeOf(Peer.prototype, EventEmitter.prototype);
/**
* Max output bytes buffered before

View File

@ -119,7 +119,7 @@ function Pool(options) {
this._init();
};
util.inherits(Pool, AsyncObject);
Object.setPrototypeOf(Pool.prototype, AsyncObject.prototype);
/**
* Discovery interval for UPNP and DNS seeds.
@ -4189,7 +4189,7 @@ function BroadcastItem(pool, msg) {
this.jobs = [];
}
util.inherits(BroadcastItem, EventEmitter);
Object.setPrototypeOf(BroadcastItem.prototype, EventEmitter.prototype);
/**
* Add a job to be executed on ack, timeout, or reject.

View File

@ -36,7 +36,7 @@ function ProxySocket(uri) {
this._init();
}
util.inherits(ProxySocket, EventEmitter);
Object.setPrototypeOf(ProxySocket.prototype, EventEmitter.prototype);
ProxySocket.prototype._init = function _init() {
this.socket.on('info', (info) => {

View File

@ -42,7 +42,7 @@ function SOCKS() {
this.proxied = false;
}
util.inherits(SOCKS, EventEmitter);
Object.setPrototypeOf(SOCKS.prototype, EventEmitter.prototype);
SOCKS.states = {
INIT: 0,
@ -553,7 +553,7 @@ function Proxy(host, port, user, pass) {
this.ops = [];
}
util.inherits(Proxy, EventEmitter);
Object.setPrototypeOf(Proxy.prototype, EventEmitter.prototype);
Proxy.prototype.connect = async function connect(port, host) {
assert(!this.socket, 'Already connected.');

View File

@ -7,8 +7,6 @@
'use strict';
const util = require('../utils/util');
const Node = require('./node');
const Chain = require('../blockchain/chain');
const Fees = require('../mempool/fees');
const Mempool = require('../mempool/mempool');
@ -16,6 +14,7 @@ const Pool = require('../net/pool');
const Miner = require('../mining/miner');
const HTTPServer = require('../http/server');
const RPC = require('../http/rpc');
const Node = require('./node');
/**
* Respresents a fullnode complete with a
@ -157,7 +156,7 @@ function FullNode(options) {
this._init();
}
util.inherits(FullNode, Node);
Object.setPrototypeOf(FullNode.prototype, Node.prototype);
/**
* Initialize the node.

View File

@ -59,7 +59,7 @@ function Node(options) {
this.init();
}
util.inherits(Node, AsyncObject);
Object.setPrototypeOf(Node.prototype, AsyncObject.prototype);
/**
* Initialize options.

View File

@ -7,13 +7,12 @@
'use strict';
const util = require('../utils/util');
const Lock = require('../utils/lock');
const Node = require('./node');
const Chain = require('../blockchain/chain');
const Pool = require('../net/pool');
const HTTPServer = require('../http/server');
const RPC = require('../http/rpc');
const Node = require('./node');
/**
* Create an spv node which only maintains
@ -104,7 +103,7 @@ function SPVNode(options) {
this._init();
}
util.inherits(SPVNode, Node);
Object.setPrototypeOf(SPVNode.prototype, Node.prototype);
/**
* Initialize the node.

View File

@ -45,7 +45,7 @@ function Block(options) {
this.fromOptions(options);
}
util.inherits(Block, AbstractBlock);
Object.setPrototypeOf(Block.prototype, AbstractBlock.prototype);
/**
* Inject properties from options object.

View File

@ -49,7 +49,7 @@ function Coin(options) {
this.fromOptions(options);
}
util.inherits(Coin, Output);
Object.setPrototypeOf(Coin.prototype, Output.prototype);
/**
* Inject options into coin.

View File

@ -30,7 +30,7 @@ function Headers(options) {
this.parseOptions(options);
}
util.inherits(Headers, AbstractBlock);
Object.setPrototypeOf(Headers.prototype, AbstractBlock.prototype);
/**
* Do non-contextual verification on the headers.

View File

@ -7,11 +7,10 @@
'use strict';
const util = require('../utils/util');
const AbstractBlock = require('./abstractblock');
const Block = require('./block');
const Script = require('../script/script');
const Headers = require('./headers');
const Script = require('../script/script');
const BufferReader = require('../utils/reader');
const DUMMY = Buffer.alloc(0);
@ -45,7 +44,7 @@ function MemBlock() {
this._raw = DUMMY;
}
util.inherits(MemBlock, AbstractBlock);
Object.setPrototypeOf(MemBlock.prototype, AbstractBlock.prototype);
/**
* Test whether the block is a memblock.

View File

@ -43,7 +43,7 @@ function MerkleBlock(options) {
this.fromOptions(options);
}
util.inherits(MerkleBlock, AbstractBlock);
Object.setPrototypeOf(MerkleBlock.prototype, AbstractBlock.prototype);
/**
* Inject properties from options object.

View File

@ -56,7 +56,7 @@ function MTX(options) {
this.fromOptions(options);
}
util.inherits(MTX, TX);
Object.setPrototypeOf(MTX.prototype, TX.prototype);
/**
* Inject properties from options object.
@ -1818,7 +1818,7 @@ function FundingError(msg, available, required) {
Error.captureStackTrace(this, FundingError);
}
util.inherits(FundingError, Error);
Object.setPrototypeOf(FundingError.prototype, Error.prototype);
/*
* Helpers

View File

@ -12,7 +12,6 @@
*/
const assert = require('assert');
const util = require('../utils/util');
/**
* An error thrown during verification. Can be either
@ -57,7 +56,7 @@ function VerifyError(msg, code, reason, score, malleated) {
Error.captureStackTrace(this, VerifyError);
}
util.inherits(VerifyError, Error);
Object.setPrototypeOf(VerifyError.prototype, Error.prototype);
/*
* Expose

View File

@ -40,7 +40,7 @@ function TimeData(limit) {
this.checked = false;
}
util.inherits(TimeData, EventEmitter);
Object.setPrototypeOf(TimeData.prototype, EventEmitter.prototype);
/**
* Add time data.

View File

@ -834,4 +834,4 @@ exports.ScriptError = function ScriptError(code, op, ip) {
Error.captureStackTrace(this, ScriptError);
};
util.inherits(exports.ScriptError, Error);
Object.setPrototypeOf(exports.ScriptError.prototype, Error.prototype);

View File

@ -8,7 +8,6 @@
const assert = require('assert');
const EventEmitter = require('events');
const util = require('./util');
const Lock = require('./lock');
/**
@ -34,7 +33,7 @@ function AsyncObject() {
this.loaded = false;
}
util.inherits(AsyncObject, EventEmitter);
Object.setPrototypeOf(AsyncObject.prototype, EventEmitter.prototype);
/**
* Open the object (recallable).

View File

@ -12,7 +12,6 @@
*/
const BN = require('bn.js');
const util = require('./util');
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
const encoding = exports;
@ -1038,7 +1037,7 @@ encoding.EncodingError = function EncodingError(offset, reason) {
Error.captureStackTrace(this, EncodingError);
};
util.inherits(encoding.EncodingError, Error);
Object.setPrototypeOf(encoding.EncodingError.prototype, Error.prototype);
/*
* Helpers

View File

@ -7,7 +7,6 @@
'use strict';
const assert = require('assert');
const util = require('../utils/util');
const BufferReader = require('../utils/reader');
/*
@ -36,7 +35,7 @@ function ProtoReader(data, zeroCopy) {
BufferReader.call(this, data, zeroCopy);
}
util.inherits(ProtoReader, BufferReader);
Object.setPrototypeOf(ProtoReader.prototype, BufferReader.prototype);
ProtoReader.prototype.readVarint = function _readVarint() {
const {size, value} = readVarint(this.data, this.offset);

View File

@ -11,7 +11,6 @@
*/
const assert = require('assert');
const util = require('../utils/util');
const BufferWriter = require('../utils/writer');
/*
@ -40,7 +39,7 @@ function ProtoWriter() {
BufferWriter.call(this);
}
util.inherits(ProtoWriter, BufferWriter);
Object.setPrototypeOf(ProtoWriter.prototype, BufferWriter.prototype);
ProtoWriter.prototype.writeVarint = function _writeVarint(num) {
const size = sizeVarint(num);

View File

@ -509,21 +509,6 @@ util.mb = function mb(size) {
return Math.floor(size / 1024 / 1024);
};
/**
* Inheritance.
* @param {Function} child - Constructor to inherit.
* @param {Function} parent - Parent constructor.
*/
util.inherits = function inherits(child, parent) {
child.super_ = parent;
Object.setPrototypeOf(child.prototype, parent.prototype);
Object.defineProperty(child.prototype, 'constructor', {
value: child,
enumerable: false
});
};
/**
* Find index of a buffer in an array of buffers.
* @param {Buffer[]} items

View File

@ -689,7 +689,7 @@ function ValidationError(key, type) {
Error.captureStackTrace(this, ValidationError);
}
util.inherits(ValidationError, Error);
Object.setPrototypeOf(ValidationError.prototype, Error.prototype);
/*
* Expose

View File

@ -44,7 +44,7 @@ function WalletClient(options) {
this.socket = null;
}
util.inherits(WalletClient, AsyncObject);
Object.setPrototypeOf(WalletClient.prototype, AsyncObject.prototype);
/**
* Open the client, wait for socket to connect.

View File

@ -52,7 +52,7 @@ function HTTPServer(options) {
this.init();
}
util.inherits(HTTPServer, HTTPBase);
Object.setPrototypeOf(HTTPServer.prototype, HTTPBase.prototype);
/**
* Attach to server.

View File

@ -6,7 +6,6 @@
'use strict';
const util = require('../utils/util');
const AsyncObject = require('../utils/asyncobject');
/**
@ -30,7 +29,7 @@ function NodeClient(node) {
this._init();
}
util.inherits(NodeClient, AsyncObject);
Object.setPrototypeOf(NodeClient.prototype, AsyncObject.prototype);
/**
* Initialize the client.

View File

@ -54,7 +54,7 @@ function RPC(wdb) {
this.init();
}
util.inherits(RPC, RPCBase);
Object.setPrototypeOf(RPC.prototype, RPCBase.prototype);
RPC.prototype.init = function init() {
this.add('help', this.help);

View File

@ -95,7 +95,7 @@ function Wallet(db, options) {
this.fromOptions(options);
}
util.inherits(Wallet, EventEmitter);
Object.setPrototypeOf(Wallet.prototype, EventEmitter.prototype);
/**
* Inject properties from options object.

View File

@ -101,7 +101,7 @@ function WalletDB(options) {
this._init();
}
util.inherits(WalletDB, AsyncObject);
Object.setPrototypeOf(WalletDB.prototype, AsyncObject.prototype);
/**
* Database layout.

View File

@ -7,7 +7,6 @@
'use strict';
const util = require('../utils/util');
const Address = require('../primitives/address');
const KeyRing = require('../primitives/keyring');
const Path = require('./path');
@ -35,7 +34,7 @@ function WalletKey(options, network) {
this.index = -1;
}
util.inherits(WalletKey, KeyRing);
Object.setPrototypeOf(WalletKey.prototype, KeyRing.prototype);
/**
* Instantiate key ring from options.

View File

@ -8,7 +8,6 @@
const assert = require('assert');
const EventEmitter = require('events');
const util = require('../utils/util');
/**
* Represents a child process.
@ -27,7 +26,7 @@ function Child(file) {
this.init(file);
}
util.inherits(Child, EventEmitter);
Object.setPrototypeOf(Child.prototype, EventEmitter.prototype);
/**
* Test whether child process support is available.

View File

@ -9,7 +9,6 @@
const EventEmitter = require('events');
const path = require('path');
const cp = require('child_process');
const util = require('../utils/util');
const children = new Set();
let exitBound = false;
@ -33,7 +32,7 @@ function Child(file) {
this.init(file);
}
util.inherits(Child, EventEmitter);
Object.setPrototypeOf(Child.prototype, EventEmitter.prototype);
/**
* Test whether child process support is available.

View File

@ -38,7 +38,7 @@ function Master() {
this.init();
}
util.inherits(Master, EventEmitter);
Object.setPrototypeOf(Master.prototype, EventEmitter.prototype);
/**
* Initialize master. Bind events.

View File

@ -11,7 +11,6 @@
*/
const assert = require('assert');
const util = require('../utils/util');
const BufferReader = require('../utils/reader');
const encoding = require('../utils/encoding');
const Script = require('../script/script');
@ -79,7 +78,7 @@ function EnvPacket(env) {
this.json = JSON.stringify(this.env);
}
util.inherits(EnvPacket, Packet);
Object.setPrototypeOf(EnvPacket.prototype, Packet.prototype);
EnvPacket.prototype.cmd = packetTypes.ENV;
@ -110,7 +109,7 @@ function EventPacket(items) {
this.json = JSON.stringify(this.items);
}
util.inherits(EventPacket, Packet);
Object.setPrototypeOf(EventPacket.prototype, Packet.prototype);
EventPacket.prototype.cmd = packetTypes.EVENT;
@ -140,7 +139,7 @@ function LogPacket(text) {
this.text = text || '';
}
util.inherits(LogPacket, Packet);
Object.setPrototypeOf(LogPacket.prototype, Packet.prototype);
LogPacket.prototype.cmd = packetTypes.LOG;
@ -169,7 +168,7 @@ function ErrorPacket(error) {
this.error = error || new Error();
}
util.inherits(ErrorPacket, Packet);
Object.setPrototypeOf(ErrorPacket.prototype, Packet.prototype);
ErrorPacket.prototype.cmd = packetTypes.ERROR;
@ -249,7 +248,7 @@ function ErrorResultPacket(error) {
ErrorPacket.call(this, error);
}
util.inherits(ErrorResultPacket, ErrorPacket);
Object.setPrototypeOf(ErrorResultPacket.prototype, ErrorPacket.prototype);
ErrorResultPacket.prototype.cmd = packetTypes.ERRORRESULT;
@ -265,7 +264,7 @@ function CheckPacket(tx, view, flags) {
this.flags = flags != null ? flags : null;
}
util.inherits(CheckPacket, Packet);
Object.setPrototypeOf(CheckPacket.prototype, Packet.prototype);
CheckPacket.prototype.cmd = packetTypes.CHECK;
@ -303,7 +302,7 @@ function CheckResultPacket(error) {
this.error = error || null;
}
util.inherits(CheckResultPacket, Packet);
Object.setPrototypeOf(CheckResultPacket.prototype, Packet.prototype);
CheckResultPacket.prototype.cmd = packetTypes.CHECKRESULT;
@ -379,7 +378,7 @@ function SignPacket(tx, rings, type) {
this.type = type != null ? type : 1;
}
util.inherits(SignPacket, Packet);
Object.setPrototypeOf(SignPacket.prototype, Packet.prototype);
SignPacket.prototype.cmd = packetTypes.SIGN;
@ -441,7 +440,7 @@ function SignResultPacket(total, witness, script) {
this.witness = witness || [];
}
util.inherits(SignResultPacket, Packet);
Object.setPrototypeOf(SignResultPacket.prototype, Packet.prototype);
SignResultPacket.prototype.cmd = packetTypes.SIGNRESULT;
@ -524,7 +523,7 @@ function CheckInputPacket(tx, index, coin, flags) {
this.flags = flags != null ? flags : null;
}
util.inherits(CheckInputPacket, Packet);
Object.setPrototypeOf(CheckInputPacket.prototype, Packet.prototype);
CheckInputPacket.prototype.cmd = packetTypes.CHECKINPUT;
@ -574,7 +573,9 @@ function CheckInputResultPacket(error) {
CheckResultPacket.call(this, error);
}
util.inherits(CheckInputResultPacket, CheckResultPacket);
Object.setPrototypeOf(
CheckInputResultPacket.prototype,
CheckResultPacket.prototype);
CheckInputResultPacket.prototype.cmd = packetTypes.CHECKINPUTRESULT;
@ -599,7 +600,7 @@ function SignInputPacket(tx, index, coin, ring, type) {
this.type = type != null ? type : 1;
}
util.inherits(SignInputPacket, Packet);
Object.setPrototypeOf(SignInputPacket.prototype, Packet.prototype);
SignInputPacket.prototype.cmd = packetTypes.SIGNINPUT;
@ -652,7 +653,7 @@ function SignInputResultPacket(value, witness, script) {
this.witness = witness || null;
}
util.inherits(SignInputResultPacket, Packet);
Object.setPrototypeOf(SignInputResultPacket.prototype, Packet.prototype);
SignInputResultPacket.prototype.cmd = packetTypes.SIGNINPUTRESULT;
@ -706,7 +707,7 @@ function ECVerifyPacket(msg, sig, key) {
this.key = key || null;
}
util.inherits(ECVerifyPacket, Packet);
Object.setPrototypeOf(ECVerifyPacket.prototype, Packet.prototype);
ECVerifyPacket.prototype.cmd = packetTypes.ECVERIFY;
@ -743,7 +744,7 @@ function ECVerifyResultPacket(value) {
this.value = value;
}
util.inherits(ECVerifyResultPacket, Packet);
Object.setPrototypeOf(ECVerifyResultPacket.prototype, Packet.prototype);
ECVerifyResultPacket.prototype.cmd = packetTypes.ECVERIFYRESULT;
@ -773,7 +774,7 @@ function ECSignPacket(msg, key) {
this.key = key || null;
}
util.inherits(ECSignPacket, Packet);
Object.setPrototypeOf(ECSignPacket.prototype, Packet.prototype);
ECSignPacket.prototype.cmd = packetTypes.ECSIGN;
@ -807,7 +808,7 @@ function ECSignResultPacket(sig) {
this.sig = sig;
}
util.inherits(ECSignResultPacket, Packet);
Object.setPrototypeOf(ECSignResultPacket.prototype, Packet.prototype);
ECSignResultPacket.prototype.cmd = packetTypes.ECSIGNRESULT;
@ -839,7 +840,7 @@ function MinePacket(data, target, min, max) {
this.max = max != null ? max : -1;
}
util.inherits(MinePacket, Packet);
Object.setPrototypeOf(MinePacket.prototype, Packet.prototype);
MinePacket.prototype.cmd = packetTypes.MINE;
@ -874,7 +875,7 @@ function MineResultPacket(nonce) {
this.nonce = nonce != null ? nonce : -1;
}
util.inherits(MineResultPacket, Packet);
Object.setPrototypeOf(MineResultPacket.prototype, Packet.prototype);
MineResultPacket.prototype.cmd = packetTypes.MINERESULT;
@ -910,7 +911,7 @@ function ScryptPacket(passwd, salt, N, r, p, len) {
this.len = len != null ? len : -1;
}
util.inherits(ScryptPacket, Packet);
Object.setPrototypeOf(ScryptPacket.prototype, Packet.prototype);
ScryptPacket.prototype.cmd = packetTypes.SCRYPT;
@ -953,7 +954,7 @@ function ScryptResultPacket(key) {
this.key = key || null;
}
util.inherits(ScryptResultPacket, Packet);
Object.setPrototypeOf(ScryptResultPacket.prototype, Packet.prototype);
ScryptResultPacket.prototype.cmd = packetTypes.SCRYPTRESULT;

View File

@ -8,7 +8,6 @@
const assert = require('assert');
const EventEmitter = require('events');
const util = require('../utils/util');
/**
* Represents the parent process.
@ -26,7 +25,7 @@ function Parent() {
this.init();
}
util.inherits(Parent, EventEmitter);
Object.setPrototypeOf(Parent.prototype, EventEmitter.prototype);
/**
* Initialize master (web workers).

View File

@ -7,7 +7,6 @@
'use strict';
const EventEmitter = require('events');
const util = require('../utils/util');
/**
* Represents the parent process.
@ -24,7 +23,7 @@ function Parent() {
this.init();
}
util.inherits(Parent, EventEmitter);
Object.setPrototypeOf(Parent.prototype, EventEmitter.prototype);
/**
* Initialize master (node.js).

View File

@ -9,7 +9,6 @@
const assert = require('assert');
const EventEmitter = require('events');
const util = require('../utils/util');
const packets = require('./packets');
/**
@ -30,7 +29,7 @@ function Parser() {
this.total = 0;
}
util.inherits(Parser, EventEmitter);
Object.setPrototypeOf(Parser.prototype, EventEmitter.prototype);
Parser.prototype.feed = function feed(data) {
this.total += data.length;

View File

@ -51,7 +51,7 @@ function WorkerPool(options) {
this.set(options);
}
util.inherits(WorkerPool, EventEmitter);
Object.setPrototypeOf(WorkerPool.prototype, EventEmitter.prototype);
/**
* Set worker pool options.
@ -378,7 +378,7 @@ function Worker(file) {
this.init();
}
util.inherits(Worker, EventEmitter);
Object.setPrototypeOf(Worker.prototype, EventEmitter.prototype);
/**
* Initialize worker. Bind to events.