Home Reference Source Test
public class | source

BaseChain

Extends:

ObservableIBlockchain → BaseChain

Direct Subclass:

FullChain, NanoChain

Indirect Subclass:

LightChain, PartialLightChain

Static Method Summary

Static Public Methods
public static

async isBetterProof(proof1: ChainProof, proof2: ChainProof, m: number): Promise<boolean>

public static

async manyPow(headers: Array<BlockHeader>): Promise<void>

Static Protected Methods
protected static

async _getProofScore(chain: BlockChain, lca: Block, m: number): Promise<number>

Constructor Summary

Public Constructor
public

Method Summary

Public Methods
public

async getBlock(hash: Hash, includeForks: boolean, includeBody: boolean): PromiseBlock>

public

getBlockAt(height: number, includeBody: boolean): PromiseBlock>

public

async getBlockLocators(): Promise<Array<Hash>>

public

getNearestBlockAt(height: number, lower: boolean): PromiseBlock>

public

async getNextTarget(block: Block, next: Block): Promise<BigNumber>

Computes the target value for the block after the given block or the head of this chain if no block is given.

public

getRawBlock(hash: Hash, includeForks: boolean): PromiseUint8Array>

public

async getSuccessorBlocks(block: Block): Promise<Array<Block>>

Protected Methods
protected

async _extendChainProof(proof: ChainProof, header: BlockHeader, failOnBadness: boolean): Promise<ChainProof>

protected

async _getBlockProof(blockToProve: Block, knownBlock: Block): PromiseBlockChain>

MUST be synchronized with .pushBlock() and variants!

protected

MUST be synchronized with .pushBlock() and variants!

Inherited Summary

From class Observable
public static get

WILDCARD: string: string

public

bubble(observable: Observable, types: ...string)

public

fire(type: string, args: ...*): Promise | null

public

off(type: string, id: number)

public

on(type: string, callback: Function): number

From class IBlockchain
public get abstract
public get abstract
public get abstract

height: number

Static Public Methods

public static async isBetterProof(proof1: ChainProof, proof2: ChainProof, m: number): Promise<boolean> source

Params:

NameTypeAttributeDescription
proof1 ChainProof
proof2 ChainProof
m number

Return:

Promise<boolean>

public static async manyPow(headers: Array<BlockHeader>): Promise<void> source

Params:

NameTypeAttributeDescription
headers Array<BlockHeader>

Return:

Promise<void>

Static Protected Methods

protected static async _getProofScore(chain: BlockChain, lca: Block, m: number): Promise<number> source

Params:

NameTypeAttributeDescription
chain BlockChain
lca Block
m number

Return:

Promise<number>

Public Constructors

public constructor(store: ChainDataStore) source

Override:

Observable#constructor

Params:

NameTypeAttributeDescription
store ChainDataStore

Public Methods

public async getBlock(hash: Hash, includeForks: boolean, includeBody: boolean): PromiseBlock> source

Params:

NameTypeAttributeDescription
hash Hash
includeForks boolean
  • optional
includeBody boolean
  • optional

Return:

PromiseBlock>

public getBlockAt(height: number, includeBody: boolean): PromiseBlock> source

Params:

NameTypeAttributeDescription
height number
includeBody boolean
  • optional

Return:

PromiseBlock>

public async getBlockLocators(): Promise<Array<Hash>> source

Return:

Promise<Array<Hash>>

public getNearestBlockAt(height: number, lower: boolean): PromiseBlock> source

Params:

NameTypeAttributeDescription
height number
lower boolean
  • optional

Return:

PromiseBlock>

public async getNextTarget(block: Block, next: Block): Promise<BigNumber> source

Computes the target value for the block after the given block or the head of this chain if no block is given.

Params:

NameTypeAttributeDescription
block Block
  • optional
next Block
  • optional

Return:

Promise<BigNumber>

public getRawBlock(hash: Hash, includeForks: boolean): PromiseUint8Array> source

Params:

NameTypeAttributeDescription
hash Hash
includeForks boolean
  • optional

Return:

PromiseUint8Array>

public async getSuccessorBlocks(block: Block): Promise<Array<Block>> source

Params:

NameTypeAttributeDescription
block Block

Return:

Promise<Array<Block>>

Protected Methods

protected async _extendChainProof(proof: ChainProof, header: BlockHeader, failOnBadness: boolean): Promise<ChainProof> source

Params:

NameTypeAttributeDescription
proof ChainProof
header BlockHeader
failOnBadness boolean
  • optional

Return:

Promise<ChainProof>

protected async _getBlockProof(blockToProve: Block, knownBlock: Block): PromiseBlockChain> source

MUST be synchronized with .pushBlock() and variants!

Params:

NameTypeAttributeDescription
blockToProve Block
knownBlock Block

Return:

PromiseBlockChain>

protected _getChainProof(): Promise<ChainProof> source

MUST be synchronized with .pushBlock() and variants!

Return:

Promise<ChainProof>