Skip to content
This repository was archived by the owner on Apr 6, 2020. It is now read-only.

Commit ec58f27

Browse files
committed
Hide internal API from docs
1 parent fdc8231 commit ec58f27

File tree

5 files changed

+34
-29
lines changed

5 files changed

+34
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": "ethereumjs-config-build",
1313
"coverage": "ethereumjs-config-coverage",
1414
"coveralls": "ethereumjs-config-coveralls",
15-
"docs:build": "typedoc --out docs --mode file --readme none --theme markdown --mdEngine github --excludeNotExported src",
15+
"docs:build": "typedoc --out docs --mode file --readme none --theme markdown --mdEngine github --excludeNotExported --excludePrivate src",
1616
"format": "ethereumjs-config-format",
1717
"format:fix": "ethereumjs-config-format-fix",
1818
"tslint": "ethereumjs-config-tslint",

src/cache.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as LRU from 'lru-cache'
22

33
/**
44
* Simple LRU Cache that allows for keys of type Buffer
5+
* @hidden
56
*/
67
export default class Cache<V> {
78
_cache: LRU<string, V>

src/dbManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const Block = require('ethereumjs-block')
1919
/**
2020
* Abstraction over a DB to facilitate storing/fetching blockchain-related
2121
* data, such as blocks and headers, indices, and the head block.
22+
* @hidden
2223
*/
2324
export default class DBManager {
2425
_cache: { [k: string]: Cache<Buffer> }

src/index.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ const level = require('level-mem')
2121
const semaphore = require('semaphore')
2222

2323
export default class Blockchain {
24-
_common: any
25-
_genesis: any
26-
_headBlock: any
27-
_headHeader: any
28-
_heads: any
29-
_initDone: boolean
30-
_initLock: any
31-
_putSemaphore: any
32-
_staleHeadBlock: any
33-
_staleHeads: any
24+
private _common: Common
25+
private _genesis: any
26+
private _headBlock: any
27+
private _headHeader: any
28+
private _heads: any
29+
private _initDone: boolean
30+
private _initLock: any
31+
private _putSemaphore: any
32+
private _staleHeadBlock: any
33+
private _staleHeads: any
3434

3535
db: any
3636
dbManager: DBManager
@@ -91,7 +91,7 @@ export default class Blockchain {
9191
* hashes of the headerchain head, blockchain head, genesis block and iterator
9292
* heads.
9393
*/
94-
_init(cb: any): void {
94+
private _init(cb: any): void {
9595
const self = this
9696

9797
async.waterfall(
@@ -148,7 +148,7 @@ export default class Blockchain {
148148
/**
149149
* Sets the default genesis block
150150
*/
151-
_setCanonicalGenesisBlock(cb: any): void {
151+
private _setCanonicalGenesisBlock(cb: any): void {
152152
const genesisBlock = new Block(null, { common: this._common })
153153
genesisBlock.setGenesisParams()
154154
this._putBlockOrHeader(genesisBlock, cb, true)
@@ -259,7 +259,7 @@ export default class Blockchain {
259259
})
260260
}
261261

262-
_putBlockOrHeader(item: any, cb: any, isGenesis?: boolean) {
262+
private _putBlockOrHeader(item: any, cb: any, isGenesis?: boolean) {
263263
const self = this
264264
const isHeader = item instanceof Block.Header
265265
let block = isHeader ? new Block([item.raw, [], []], { common: item._common }) : item
@@ -523,7 +523,7 @@ export default class Blockchain {
523523
)
524524
}
525525

526-
_saveHeadOps() {
526+
private _saveHeadOps() {
527527
return [
528528
{
529529
type: 'put',
@@ -549,14 +549,14 @@ export default class Blockchain {
549549
]
550550
}
551551

552-
_saveHeads(cb: any) {
552+
private _saveHeads(cb: any) {
553553
this._batchDbOps(this._saveHeadOps(), cb)
554554
}
555555

556556
/**
557557
* Delete canonical number assignments for specified number and above
558558
*/
559-
_deleteStaleAssignments(number: BN, headHash: Buffer, ops: any, cb: any) {
559+
private _deleteStaleAssignments(number: BN, headHash: Buffer, ops: any, cb: any) {
560560
const key = numberToHashKey(number)
561561

562562
this._numberToHash(number, (err?: any, hash?: Buffer) => {
@@ -586,7 +586,7 @@ export default class Blockchain {
586586
}
587587

588588
// overwrite stale canonical number assignments
589-
_rebuildCanonical(header: any, ops: any, cb: any) {
589+
private _rebuildCanonical(header: any, ops: any, cb: any) {
590590
const self = this
591591
const hash = header.hash()
592592
const number = new BN(header.number)
@@ -677,7 +677,7 @@ export default class Blockchain {
677677
})
678678
}
679679

680-
_delBlock(blockHash: Buffer | typeof Block, cb: any) {
680+
private _delBlock(blockHash: Buffer | typeof Block, cb: any) {
681681
const self = this
682682
const dbOps: any[] = []
683683
let blockHeader = null
@@ -734,7 +734,7 @@ export default class Blockchain {
734734
}
735735
}
736736

737-
_delChild(hash: Buffer, number: BN, headHash: Buffer, ops: any, cb: any) {
737+
private _delChild(hash: Buffer, number: BN, headHash: Buffer, ops: any, cb: any) {
738738
const self = this
739739

740740
// delete header, body, hash to number mapping and td
@@ -798,7 +798,7 @@ export default class Blockchain {
798798
})
799799
}
800800

801-
_iterator(name: string, func: any, cb: any) {
801+
private _iterator(name: string, func: any, cb: any) {
802802
const self = this
803803
const blockHash = self._heads[name] || self._genesis
804804
let blockNumber: any
@@ -851,28 +851,28 @@ export default class Blockchain {
851851
/**
852852
* Executes multiple db operations in a single batch call
853853
*/
854-
_batchDbOps(dbOps: any, cb: any): void {
854+
private _batchDbOps(dbOps: any, cb: any): void {
855855
util.callbackify(this.dbManager.batch.bind(this.dbManager))(dbOps, cb)
856856
}
857857

858858
/**
859859
* Performs a block hash to block number lookup
860860
*/
861-
_hashToNumber(hash: Buffer, cb: any): void {
861+
private _hashToNumber(hash: Buffer, cb: any): void {
862862
util.callbackify(this.dbManager.hashToNumber.bind(this.dbManager))(hash, cb)
863863
}
864864

865865
/**
866866
* Performs a block number to block hash lookup
867867
*/
868-
_numberToHash(number: BN, cb: any): void {
868+
private _numberToHash(number: BN, cb: any): void {
869869
util.callbackify(this.dbManager.numberToHash.bind(this.dbManager))(number, cb)
870870
}
871871

872872
/**
873873
* Helper function to lookup a block by either hash only or a hash and number pair
874874
*/
875-
_lookupByHashNumber(hash: Buffer, number: BN, cb: any, next: any): void {
875+
private _lookupByHashNumber(hash: Buffer, number: BN, cb: any, next: any): void {
876876
if (typeof number === 'function') {
877877
cb = number
878878
return this._hashToNumber(hash, (err?: any, number?: BN) => {
@@ -888,7 +888,7 @@ export default class Blockchain {
888888
/**
889889
* Gets a header by hash and number. Header can exist outside the canonical chain
890890
*/
891-
_getHeader(hash: Buffer, number: any, cb?: any): void {
891+
private _getHeader(hash: Buffer, number: any, cb?: any): void {
892892
this._lookupByHashNumber(
893893
hash,
894894
number,
@@ -905,7 +905,7 @@ export default class Blockchain {
905905
/**
906906
* Gets a header by number. Header must be in the canonical chain
907907
*/
908-
_getCanonicalHeader(number: BN, cb: any): void {
908+
private _getCanonicalHeader(number: BN, cb: any): void {
909909
this._numberToHash(number, (err: Error | undefined, hash: Buffer) => {
910910
if (err) {
911911
return cb(err)
@@ -917,7 +917,7 @@ export default class Blockchain {
917917
/**
918918
* Gets total difficulty for a block specified by hash and number
919919
*/
920-
_getTd(hash: any, number: any, cb?: any): void {
920+
private _getTd(hash: any, number: any, cb?: any): void {
921921
this._lookupByHashNumber(
922922
hash,
923923
number,
@@ -931,7 +931,7 @@ export default class Blockchain {
931931
)
932932
}
933933

934-
_lockUnlock(fn: any, cb: any): void {
934+
private _lockUnlock(fn: any, cb: any): void {
935935
const self = this
936936
this._putSemaphore.take(() => {
937937
fn(after)

src/util.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ const bodyKey = (n: BN, hash: Buffer) => Buffer.concat([bodyPrefix, bufBE8(n), h
4444
const numberToHashKey = (n: BN) => Buffer.concat([headerPrefix, bufBE8(n), numSuffix])
4545
const hashToNumberKey = (hash: Buffer) => Buffer.concat([blockHashPrefix, hash])
4646

47+
/**
48+
* @hidden
49+
*/
4750
export {
4851
headsKey,
4952
headHeaderKey,

0 commit comments

Comments
 (0)