Skip to content

Commit ae4683e

Browse files
committed
fixed benchmark.ts in bitcore-node
1 parent b1bb901 commit ae4683e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/bitcore-lib/lib/publickey.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ PublicKey.prototype._getID = function _getID() {
467467
/**
468468
* Will return an address for the public key
469469
*
470-
* @param {String|Network=} network - Which network should the address be for
471-
* @param {string} type - Either 'pubkeyhash', 'witnesspubkeyhash', or 'scripthash'
470+
* @param {String|Network=} [network] - Which network should the address be for
471+
* @param {string} [type] - Either 'pubkeyhash', 'witnesspubkeyhash', or 'scripthash'
472472
* @returns {Address} An address generated from the public key
473473
*/
474474
PublicKey.prototype.toAddress = function(network, type) {

packages/bitcore-node/test/benchmark/benchmark.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { BitcoinBlockStorage } from '../../src/models/block';
99
import { BitcoinBlockType } from '../../src/types/namespaces/Bitcoin/Block';
1010
import { resetDatabase } from '../helpers/index.js';
1111
import * as crypto from 'crypto';
12+
import { BitcoinTransactionType } from '../../src/types/namespaces/Bitcoin/Transaction';
1213

1314
function randomHash() {
1415
return crypto.randomBytes(32).toString('hex');
@@ -71,13 +72,13 @@ function generateBlock(blockSizeMb: number, previousBlock?: BitcoinBlockType): B
7172
return new UnspentOutput({
7273
txid: transaction.hash,
7374
vout: 0,
74-
address: output.script.toAddress('mainnet'),
75+
address: output.script.toAddress('mainnet').toString(false),
7576
scriptPubKey: output.script.toBuffer().toString('hex'),
7677
amount: Number(txAmount)
7778
});
7879
});
7980
const newTx = new Transaction().from(utxos);
80-
for (const _ of newTx.inputs) {
81+
for (const _ of newTx.inputs!) {
8182
newTx.to(newAddress(), txAmount);
8283
}
8384
transactions.push(newTx);
@@ -87,7 +88,7 @@ function generateBlock(blockSizeMb: number, previousBlock?: BitcoinBlockType): B
8788
const txPerMb = 2500;
8889
const blockSize = txPerMb * blockSizeMb;
8990
for (let i = 0; i < blockSize; i++) {
90-
const newTx = new Transaction().to(newAddress(), txAmount);
91+
const newTx = new Transaction().to(newAddress(), txAmount) as BitcoinTransactionType;
9192
block.transactions.push(newTx);
9293
}
9394
}

0 commit comments

Comments
 (0)