Skip to content

Commit 031c5b7

Browse files
committed
types: update mempool entries and simple mining.
1 parent e13f180 commit 031c5b7

File tree

9 files changed

+209
-53
lines changed

9 files changed

+209
-53
lines changed

lib/blockstore/abstract.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,9 @@ class AbstractBatch {
298298
}
299299
}
300300

301-
AbstractBlockStore.AbstractBatch = AbstractBatch;
302-
303301
/*
304302
* Expose
305303
*/
306304

305+
AbstractBlockStore.AbstractBatch = AbstractBatch;
307306
module.exports = AbstractBlockStore;

lib/hd/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ common.MAX_ENTROPY = 512;
3939

4040
/**
4141
* LRU cache to avoid deriving keys twice.
42-
* @type {LRU<HDPublicKey|HDPrivateKey>}
42+
* @type {LRU<String, HDPublicKey|HDPrivateKey>}
4343
*/
4444

4545
common.cache = new LRU(500);

lib/mempool/airdropentry.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ const policy = require('../protocol/policy');
1212
const util = require('../utils/util');
1313
const Address = require('../primitives/address');
1414

15+
/** @typedef {import('../types').Amount} AmountValue */
16+
/** @typedef {import('../types').Rate} Rate */
17+
/** @typedef {import('../types').BufioWriter} BufioWriter */
18+
/** @typedef {import('../primitives/airdropproof')} AirdropProof */
19+
1520
/*
1621
* Constants
1722
*/
@@ -73,7 +78,6 @@ class AirdropEntry extends bio.Struct {
7378

7479
/**
7580
* Inject properties from airdrop.
76-
* @private
7781
* @param {AirdropProof} proof
7882
* @param {Number} height
7983
*/
@@ -99,7 +103,6 @@ class AirdropEntry extends bio.Struct {
99103
/**
100104
* Create a mempool entry from an airdrop proof.
101105
* @param {AirdropProof} proof
102-
* @param {Object} data
103106
* @param {Number} height - Entry height.
104107
* @returns {AirdropEntry}
105108
*/
@@ -110,7 +113,7 @@ class AirdropEntry extends bio.Struct {
110113

111114
/**
112115
* Get fee.
113-
* @returns {Amount}
116+
* @returns {AmountValue}
114117
*/
115118

116119
getFee() {
@@ -160,7 +163,8 @@ class AirdropEntry extends bio.Struct {
160163

161164
/**
162165
* Serialize entry to a buffer.
163-
* @returns {Buffer}
166+
* @param {BufioWriter} bw
167+
* @returns {BufioWriter}
164168
*/
165169

166170
write(bw) {
@@ -180,9 +184,8 @@ class AirdropEntry extends bio.Struct {
180184

181185
/**
182186
* Inject properties from serialized data.
183-
* @private
184-
* @param {Buffer} data
185-
* @returns {AirdropEntry}
187+
* @param {bio.BufferReader} br
188+
* @returns {this}
186189
*/
187190

188191
read(br) {

lib/mempool/claimentry.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const util = require('../utils/util');
1313
const Address = require('../primitives/address');
1414
const rules = require('../covenants/rules');
1515

16+
/** @typedef {import('../primitives/claim')} Claim */
17+
/** @typedef {import('../types').Amount} AmountValue */
18+
/** @typedef {import('../types').Rate} Rate */
19+
/** @typedef {import('../types').BufioWriter} BufioWriter */
20+
1621
/*
1722
* Constants
1823
*/
@@ -58,7 +63,6 @@ class ClaimEntry extends bio.Struct {
5863

5964
/**
6065
* Inject properties from options object.
61-
* @private
6266
* @param {Object} options
6367
*/
6468

@@ -84,7 +88,6 @@ class ClaimEntry extends bio.Struct {
8488

8589
/**
8690
* Inject properties from claim.
87-
* @private
8891
* @param {Claim} claim
8992
* @param {Object} data
9093
* @param {Number} height
@@ -128,7 +131,7 @@ class ClaimEntry extends bio.Struct {
128131

129132
/**
130133
* Get fee.
131-
* @returns {Amount}
134+
* @returns {AmountValue}
132135
*/
133136

134137
getFee() {
@@ -178,7 +181,8 @@ class ClaimEntry extends bio.Struct {
178181

179182
/**
180183
* Serialize entry to a buffer.
181-
* @returns {Buffer}
184+
* @param {BufioWriter} bw
185+
* @returns {BufioWriter}
182186
*/
183187

184188
write(bw) {
@@ -204,9 +208,8 @@ class ClaimEntry extends bio.Struct {
204208

205209
/**
206210
* Inject properties from serialized data.
207-
* @private
208-
* @param {Buffer} data
209-
* @returns {ClaimEntry}
211+
* @param {bio.BufferReader} br
212+
* @returns {this}
210213
*/
211214

212215
read(br) {

lib/mempool/mempoolentry.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ const policy = require('../protocol/policy');
1111
const util = require('../utils/util');
1212
const TX = require('../primitives/tx');
1313

14+
/** @typedef {import('../types').Hash} Hash */
15+
/** @typedef {import('../types').HexHash} HexHash */
16+
/** @typedef {import('../types').Amount} AmountValue */
17+
/** @typedef {import('../types').Rate} Rate */
18+
/** @typedef {import('../types').BufioWriter} BufioWriter */
19+
/** @typedef {import('../coins/coinview')} CoinView */
20+
1421
/**
1522
* Mempool Entry
1623
* Represents a mempool entry.
@@ -26,12 +33,12 @@ class MempoolEntry extends bio.Struct {
2633
/**
2734
* Create a mempool entry.
2835
* @constructor
29-
* @param {Object} options
36+
* @param {Object} [options]
3037
* @param {TX} options.tx - Transaction in mempool.
3138
* @param {Number} options.height - Entry height.
3239
* @param {Number} options.priority - Entry priority.
3340
* @param {Number} options.time - Entry time.
34-
* @param {Amount} options.value - Value of on-chain coins.
41+
* @param {AmountValue} options.value - Value of on-chain coins.
3542
*/
3643

3744
constructor(options) {
@@ -57,7 +64,6 @@ class MempoolEntry extends bio.Struct {
5764

5865
/**
5966
* Inject properties from options object.
60-
* @private
6167
* @param {Object} options
6268
*/
6369

@@ -80,8 +86,8 @@ class MempoolEntry extends bio.Struct {
8086

8187
/**
8288
* Inject properties from transaction.
83-
* @private
8489
* @param {TX} tx
90+
* @param {CoinView} view
8591
* @param {Number} height
8692
*/
8793

@@ -123,6 +129,7 @@ class MempoolEntry extends bio.Struct {
123129
/**
124130
* Create a mempool entry from a TX.
125131
* @param {TX} tx
132+
* @param {CoinView} view
126133
* @param {Number} height - Entry height.
127134
* @returns {MempoolEntry}
128135
*/
@@ -171,7 +178,7 @@ class MempoolEntry extends bio.Struct {
171178

172179
/**
173180
* Get fee.
174-
* @returns {Amount}
181+
* @returns {AmountValue}
175182
*/
176183

177184
getFee() {
@@ -180,7 +187,7 @@ class MempoolEntry extends bio.Struct {
180187

181188
/**
182189
* Get delta fee.
183-
* @returns {Amount}
190+
* @returns {AmountValue}
184191
*/
185192

186193
getDeltaFee() {
@@ -284,7 +291,8 @@ class MempoolEntry extends bio.Struct {
284291

285292
/**
286293
* Serialize entry to a buffer.
287-
* @returns {Buffer}
294+
* @param {BufioWriter} bw
295+
* @returns {BufioWriter}
288296
*/
289297

290298
write(bw) {
@@ -303,9 +311,8 @@ class MempoolEntry extends bio.Struct {
303311

304312
/**
305313
* Inject properties from serialized data.
306-
* @private
307-
* @param {Buffer} data
308-
* @returns {MempoolEntry}
314+
* @param {bio.BufferReader} br
315+
* @returns {this}
309316
*/
310317

311318
read(br) {

lib/mining/common.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const B0 = 0x1;
3434

3535
common.swap32 = function swap32(data) {
3636
for (let i = 0; i < data.length; i += 4) {
37-
const field = data.readUInt32LE(i, true);
38-
data.writeUInt32BE(field, i, true);
37+
const field = data.readUInt32LE(i);
38+
data.writeUInt32BE(field, i);
3939
}
4040

4141
return data;
@@ -53,20 +53,20 @@ common.double256 = function double256(target) {
5353

5454
assert(target.length === 32);
5555

56-
hi = target.readUInt32BE(0, true);
57-
lo = target.readUInt32BE(4, true);
56+
hi = target.readUInt32BE(0);
57+
lo = target.readUInt32BE(4);
5858
n += (hi * 0x100000000 + lo) * B192;
5959

60-
hi = target.readUInt32BE(8, true);
61-
lo = target.readUInt32BE(12, true);
60+
hi = target.readUInt32BE(8);
61+
lo = target.readUInt32BE(12);
6262
n += (hi * 0x100000000 + lo) * B128;
6363

64-
hi = target.readUInt32BE(16, true);
65-
lo = target.readUInt32BE(20, true);
64+
hi = target.readUInt32BE(16);
65+
lo = target.readUInt32BE(20);
6666
n += (hi * 0x100000000 + lo) * B64;
6767

68-
hi = target.readUInt32BE(24, true);
69-
lo = target.readUInt32BE(28, true);
68+
hi = target.readUInt32BE(24);
69+
lo = target.readUInt32BE(28);
7070
n += (hi * 0x100000000 + lo) * B0;
7171

7272
return n;
@@ -113,7 +113,7 @@ common.getTarget = function getTarget(bits) {
113113
/**
114114
* Get bits from target.
115115
* @param {Buffer} data
116-
* @returns {Buffer}
116+
* @returns {Number}
117117
*/
118118

119119
common.getBits = function getBits(data) {

0 commit comments

Comments
 (0)