refactor: cleanup for..of loops.
This commit is contained in:
parent
6f1f81dcbe
commit
02e4dda012
@ -1460,7 +1460,6 @@ RPC.prototype.getMiningInfo = async function getMiningInfo(args, help) {
|
||||
let weight = 0;
|
||||
let txs = 0;
|
||||
let diff = 0;
|
||||
let item;
|
||||
|
||||
if (help || args.length !== 0)
|
||||
throw new RPCError(errs.MISC_ERROR, 'getmininginfo');
|
||||
@ -1470,7 +1469,7 @@ RPC.prototype.getMiningInfo = async function getMiningInfo(args, help) {
|
||||
txs = attempt.items.length + 1;
|
||||
diff = attempt.getDifficulty();
|
||||
size = 1000;
|
||||
for (item of attempt.items)
|
||||
for (let item of attempt.items)
|
||||
size += item.tx.getBaseSize();
|
||||
}
|
||||
|
||||
|
||||
@ -625,8 +625,6 @@ PolicyEstimator.prototype.processBlockTX = function processBlockTX(height, entry
|
||||
*/
|
||||
|
||||
PolicyEstimator.prototype.processBlock = function processBlock(height, entries, current) {
|
||||
let entry;
|
||||
|
||||
// Ignore reorgs.
|
||||
if (height <= this.bestHeight)
|
||||
return;
|
||||
@ -673,7 +671,7 @@ PolicyEstimator.prototype.processBlock = function processBlock(height, entries,
|
||||
this.feeStats.clearCurrent(height);
|
||||
this.priStats.clearCurrent(height);
|
||||
|
||||
for (entry of entries)
|
||||
for (let entry of entries)
|
||||
this.processBlockTX(height, entry);
|
||||
|
||||
this.feeStats.updateAverages();
|
||||
|
||||
@ -357,11 +357,9 @@ Witness.prototype.getVarSize = function getVarSize() {
|
||||
*/
|
||||
|
||||
Witness.prototype.toWriter = function toWriter(bw) {
|
||||
let item;
|
||||
|
||||
bw.writeVarint(this.items.length);
|
||||
|
||||
for (item of this.items)
|
||||
for (let item of this.items)
|
||||
bw.writeVarBytes(item);
|
||||
|
||||
return bw;
|
||||
|
||||
@ -537,7 +537,7 @@ Account.prototype.derivePath = function derivePath(path, master) {
|
||||
|
||||
Account.prototype.deriveKey = function deriveKey(branch, index, master) {
|
||||
let keys = [];
|
||||
let key, shared, ring;
|
||||
let key, ring;
|
||||
|
||||
assert(typeof branch === 'number');
|
||||
|
||||
@ -556,7 +556,7 @@ Account.prototype.deriveKey = function deriveKey(branch, index, master) {
|
||||
case Account.types.MULTISIG:
|
||||
keys.push(key.publicKey);
|
||||
|
||||
for (shared of this.keys) {
|
||||
for (let shared of this.keys) {
|
||||
shared = shared.derive(branch).derive(index);
|
||||
keys.push(shared.publicKey);
|
||||
}
|
||||
|
||||
@ -615,11 +615,10 @@ HTTPServer.prototype.initRouter = function initRouter() {
|
||||
let acct = valid.str('account');
|
||||
let coins = await req.wallet.getCoins(acct);
|
||||
let result = [];
|
||||
let coin;
|
||||
|
||||
common.sortCoins(coins);
|
||||
|
||||
for (coin of coins)
|
||||
for (let coin of coins)
|
||||
result.push(coin.getJSON(this.network));
|
||||
|
||||
res.send(200, result);
|
||||
@ -629,9 +628,8 @@ HTTPServer.prototype.initRouter = function initRouter() {
|
||||
this.get('/:id/locked', async (req, res) => {
|
||||
let locked = this.wallet.getLocked();
|
||||
let result = [];
|
||||
let outpoint;
|
||||
|
||||
for (outpoint of locked)
|
||||
for (let outpoint of locked)
|
||||
result.push(outpoint.toJSON());
|
||||
|
||||
res.send(200, result);
|
||||
@ -840,9 +838,8 @@ HTTPServer.prototype.initSockets = function initSockets() {
|
||||
this.walletdb.on('address', (id, receive) => {
|
||||
let channel = 'w:' + id;
|
||||
let json = [];
|
||||
let addr;
|
||||
|
||||
for (addr of receive)
|
||||
for (let addr of receive)
|
||||
json.push(addr.toJSON());
|
||||
|
||||
this.to(channel, 'wallet address', json);
|
||||
|
||||
@ -1537,13 +1537,13 @@ Wallet.prototype.estimateSize = async function estimateSize(prev) {
|
||||
Wallet.prototype.createTX = async function createTX(options, force) {
|
||||
let outputs = options.outputs;
|
||||
let mtx = new MTX();
|
||||
let output, addr, total;
|
||||
let addr, total;
|
||||
|
||||
assert(Array.isArray(outputs), 'Outputs must be an array.');
|
||||
assert(outputs.length > 0, 'No outputs available.');
|
||||
|
||||
// Add the outputs
|
||||
for (output of outputs) {
|
||||
for (let output of outputs) {
|
||||
output = new Output(output);
|
||||
addr = output.getAddress();
|
||||
|
||||
|
||||
@ -182,14 +182,12 @@ WalletDB.prototype._open = async function open() {
|
||||
*/
|
||||
|
||||
WalletDB.prototype._close = async function close() {
|
||||
let wallet;
|
||||
|
||||
await this.disconnect();
|
||||
|
||||
if (this.http && this.options.listen)
|
||||
await this.http.close();
|
||||
|
||||
for (wallet of this.wallets.values())
|
||||
for (let wallet of this.wallets.values())
|
||||
await wallet.destroy();
|
||||
|
||||
await this.db.close();
|
||||
@ -1460,15 +1458,13 @@ WalletDB.prototype.decryptKeys = async function decryptKeys(wallet, key) {
|
||||
*/
|
||||
|
||||
WalletDB.prototype.resend = async function resend() {
|
||||
let keys, key, wid;
|
||||
|
||||
keys = await this.db.keys({
|
||||
let keys = await this.db.keys({
|
||||
gte: layout.w(0x00000000),
|
||||
lte: layout.w(0xffffffff)
|
||||
});
|
||||
|
||||
for (key of keys) {
|
||||
wid = layout.ww(key);
|
||||
for (let key of keys) {
|
||||
let wid = layout.ww(key);
|
||||
await this.resendPending(wid);
|
||||
}
|
||||
};
|
||||
@ -1926,7 +1922,6 @@ WalletDB.prototype.addBlock = async function addBlock(entry, txs) {
|
||||
WalletDB.prototype._addBlock = async function addBlock(entry, txs) {
|
||||
let tip = BlockMeta.fromEntry(entry);
|
||||
let total = 0;
|
||||
let tx;
|
||||
|
||||
if (tip.height < this.state.height) {
|
||||
this.logger.warning(
|
||||
@ -1955,7 +1950,7 @@ WalletDB.prototype._addBlock = async function addBlock(entry, txs) {
|
||||
return total;
|
||||
}
|
||||
|
||||
for (tx of txs) {
|
||||
for (let tx of txs) {
|
||||
if (await this._insert(tx, tip))
|
||||
total++;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user