Home Reference Source Test
public class | source

BaseConsensus

Extends:

Observable → BaseConsensus

Indirect Subclass:

NanoConsensus, PicoConsensus

Constructor Summary

Public Constructor
public

constructor(blockchain: BaseChain, mempool: Observable, network: Network)

Member Summary

Public Members
public get

established: boolean

public get
public get
Protected Members
protected

_established: boolean

Method Summary

Public Methods
public abstract

async getAccounts(addresses: Array<Address>): Promise<Array<Account>>

public

async getBlock(hash: Hash, includeBody: boolean, includeBodyFromLocal: boolean, blockHeight: number): Promise<Block>

public

async getBlockAt(height: number, includeBody: boolean): Promise<Block>

public

async getBlockTemplate(minerAddress: Address, extraData: Uint8Array): Promise<Block>

public

async getHeadHash(): Promise<Hash>

public

async getHeadHeight(): Promise<number>

public
public

getPendingTransactions(hashes: Array<Hash>): Promise<Array<Transaction>>

public

async getPendingTransactionsByAddress(address: Address): Promise<Array<Transaction>>

public
public
public

getTransactionReceiptsByHashes(hashes: Array<Hash>): Promise<Array<TransactionReceipt>>

public

async getTransactionsFromBlock(hashes: Array<Hash>, blockHash: Hash, blockHeight: number, block: Block): Promise<Array<Transaction>>

public

async getTransactionsFromBlockByAddresses(addresses: Array<Address>, blockHash: Hash, blockHeight: number): Promise<Array<Transaction>>

public
public abstract

async sendTransaction(tx: Transaction): Promise<BaseConsensus.SendTransactionResult>

public

async submitBlock(block: Block): Promise<boolean>

public

subscribe(subscription: Subscription)

Protected Methods
protected
protected

_hasEnoughPeers(numSyncedFullNodes: number, numSyncedNodes: number): boolean

protected
protected
protected
protected

_onPeerLeft(peer: Peer)

protected
protected
protected

_onToDisconnect(obj: Observable, type: string, callback: function)

protected
protected
protected

async _requestBlockProof(blockHashToProve: Hash, blockHeightToProve: number): Promise<Block>

protected

async _requestBlockProofAt(blockHeightToProve: number): Promise<Block>

protected

async _requestTransactionHistory(address: Address): Promise<Array<{transaction: Transaction, header: BlockHeader}>>

this method was deprecated.
protected
protected

async _requestTransactionsByAddresses(addresses: Array<Address>, block: Block): Promise<Array<Transaction>>

protected

Inherited Summary

From class Observable
public static get

WILDCARD: string: string

public

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

public

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

public

off(type: string, id: number)

public

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

Public Constructors

public constructor(blockchain: BaseChain, mempool: Observable, network: Network) source

Override:

Observable#constructor

Params:

NameTypeAttributeDescription
blockchain BaseChain
mempool Observable
network Network

Public Members

public get established: boolean source

public get invRequestManager: InvRequestManager source

public get network: Network source

Protected Members

protected _established: boolean source

Public Methods

public abstract async getAccounts(addresses: Array<Address>): Promise<Array<Account>> source

Params:

NameTypeAttributeDescription
addresses Array<Address>

Return:

Promise<Array<Account>>

public async getBlock(hash: Hash, includeBody: boolean, includeBodyFromLocal: boolean, blockHeight: number): Promise<Block> source

Params:

NameTypeAttributeDescription
hash Hash
includeBody boolean
  • optional
  • default: true
includeBodyFromLocal boolean
  • optional
blockHeight number
  • optional

Return:

Promise<Block>

public async getBlockAt(height: number, includeBody: boolean): Promise<Block> source

Params:

NameTypeAttributeDescription
height number
includeBody boolean
  • optional
  • default: true

Return:

Promise<Block>

public async getBlockTemplate(minerAddress: Address, extraData: Uint8Array): Promise<Block> source

Params:

NameTypeAttributeDescription
minerAddress Address
extraData Uint8Array
  • optional

Return:

Promise<Block>

public async getHeadHash(): Promise<Hash> source

Return:

Promise<Hash>

public async getHeadHeight(): Promise<number> source

Return:

Promise<number>

public getMempoolContents(): Array<Transaction> source

Return:

Array<Transaction>

public getPendingTransactions(hashes: Array<Hash>): Promise<Array<Transaction>> source

Params:

NameTypeAttributeDescription
hashes Array<Hash>

Return:

Promise<Array<Transaction>>

public async getPendingTransactionsByAddress(address: Address): Promise<Array<Transaction>> source

Params:

NameTypeAttributeDescription
address Address

Return:

Promise<Array<Transaction>>

public getSubscription(): Subscription source

Return:

Subscription

public getTransactionReceiptsByAddress(address: Address): Promise<Array<TransactionReceipt>> source

Params:

NameTypeAttributeDescription
address Address

Return:

Promise<Array<TransactionReceipt>>

public getTransactionReceiptsByHashes(hashes: Array<Hash>): Promise<Array<TransactionReceipt>> source

Params:

NameTypeAttributeDescription
hashes Array<Hash>

Return:

Promise<Array<TransactionReceipt>>

public async getTransactionsFromBlock(hashes: Array<Hash>, blockHash: Hash, blockHeight: number, block: Block): Promise<Array<Transaction>> source

Params:

NameTypeAttributeDescription
hashes Array<Hash>
blockHash Hash
blockHeight number
  • optional
block Block
  • optional

Return:

Promise<Array<Transaction>>

public async getTransactionsFromBlockByAddresses(addresses: Array<Address>, blockHash: Hash, blockHeight: number): Promise<Array<Transaction>> source

Params:

NameTypeAttributeDescription
addresses Array<Address>
blockHash Hash
blockHeight number
  • optional

Return:

Promise<Array<Transaction>>

public handoverTo(consensus: BaseConsensus): BaseConsensus source

Params:

NameTypeAttributeDescription
consensus BaseConsensus

Return:

BaseConsensus

public abstract async sendTransaction(tx: Transaction): Promise<BaseConsensus.SendTransactionResult> source

Params:

NameTypeAttributeDescription
tx Transaction

Return:

Promise<BaseConsensus.SendTransactionResult>

public async submitBlock(block: Block): Promise<boolean> source

Params:

NameTypeAttributeDescription
block Block

Return:

Promise<boolean>

public subscribe(subscription: Subscription) source

Params:

NameTypeAttributeDescription
subscription Subscription

Protected Methods

protected _disconnectListeners() source

protected _hasEnoughPeers(numSyncedFullNodes: number, numSyncedNodes: number): boolean source

Params:

NameTypeAttributeDescription
numSyncedFullNodes number
numSyncedNodes number

Return:

boolean

protected _newConsensusAgent(peer: Peer): BaseConsensusAgent source

Params:

NameTypeAttributeDescription
peer Peer

protected _onHeadChanged(head: Block) source

Params:

NameTypeAttributeDescription
head Block

protected _onPeerJoined(peer: Peer): BaseConsensusAgent source

Params:

NameTypeAttributeDescription
peer Peer

protected _onPeerLeft(peer: Peer) source

Params:

NameTypeAttributeDescription
peer Peer

protected _onPeerOutOfSync(peer: Peer) source

Params:

NameTypeAttributeDescription
peer Peer

protected _onPeerSynced(peer: Peer) source

Params:

NameTypeAttributeDescription
peer Peer

protected _onToDisconnect(obj: Observable, type: string, callback: function) source

Params:

NameTypeAttributeDescription
obj Observable
type string
callback function

protected _onTransactionAdded(tx: Transaction) source

Params:

NameTypeAttributeDescription
tx Transaction

protected _onTransactionRemoved(tx: Transaction) source

Params:

NameTypeAttributeDescription
tx Transaction

protected async _requestBlockProof(blockHashToProve: Hash, blockHeightToProve: number): Promise<Block> source

Params:

NameTypeAttributeDescription
blockHashToProve Hash
blockHeightToProve number

Return:

Promise<Block>

protected async _requestBlockProofAt(blockHeightToProve: number): Promise<Block> source

Params:

NameTypeAttributeDescription
blockHeightToProve number

Return:

Promise<Block>

protected async _requestTransactionHistory(address: Address): Promise<Array<{transaction: Transaction, header: BlockHeader}>> source

this method was deprecated.

Params:

NameTypeAttributeDescription
address Address

Return:

Promise<Array<{transaction: Transaction, header: BlockHeader}>>

protected async _requestTransactionReceiptsByAddress(address: Address): Promise<Array<TransactionReceipt>> source

Params:

NameTypeAttributeDescription
address Address

Return:

Promise<Array<TransactionReceipt>>

protected async _requestTransactionsByAddresses(addresses: Array<Address>, block: Block): Promise<Array<Transaction>> source

Params:

NameTypeAttributeDescription
addresses Array<Address>
block Block
  • optional

Return:

Promise<Array<Transaction>>

protected _syncBlockchain() source