Home Reference Source Test
public class | source

BaseConsensusAgent

Extends:

Observable → BaseConsensusAgent

Indirect Subclass:

LightConsensusAgent

Constructor Summary

Public Constructor
public

constructor(time: Time, peer: Peer, invRequestManager: InvRequestManager, targetSubscription: Subscription)

Member Summary

Public Members
public get
public get

synced: boolean

public get

syncing: boolean

Method Summary

Public Methods
public

getBlockProof(blockHashToProve: Hash, knownBlock: Block): Promise<Block>

public
public

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

public

knowsBlock(blockHash: Hash): boolean

public
public

relayBlock(block: Block): boolean

public

relayTransaction(transaction: Transaction): boolean

public
public
public

subscribe(subscription: Subscription)

Protected Methods
protected

async __onInv(msg: InvMessage): Promise<void>

protected

_doRequestData(vectors: Array<InvVector>): void

protected abstract

_getBlock(hash: Hash, includeForks: boolean, includeBody: boolean): PromiseBlock>

protected abstract

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

protected abstract
protected

_noMoreData(): void

protected
protected
protected

async _onBlock(msg: BlockMessage): Promise<void>

protected

_onClose(): void

protected

async _onGetData(msg: GetDataMessage): Promise<void>

protected

async _onGetHeader(msg: GetHeaderMessage): Promise

protected

async _onHeader(msg: HeaderMessage): Promise<void>

protected

_onInv(msg: InvMessage): Promise<void>

protected

_onKnownBlockAnnounced(hash: Hash, block: Block): void

protected

_onKnownTransactionAnnounced(hash: Hash, transaction: Transaction): void

protected

_onNewBlockAnnounced(hash: Hash): void

protected
protected
protected
protected

_onObjectProcessed(vector: InvVector): void

protected

_onObjectReceived(vector: InvVector): void

protected
protected

async _onTx(msg: TxMessage): Promise

protected

async _processBlock(hash: Hash, block: Block): Promise<void>

protected

async _processHeader(hash: Hash, header: BlockHeader): Promise<void>

protected

async _processTransaction(hash: Hash, transaction: Transaction): Promise<void>

protected

_requestData(): void

protected

_shouldRequestData(vector: InvVector): boolean

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

Public Constructors

public constructor(time: Time, peer: Peer, invRequestManager: InvRequestManager, targetSubscription: Subscription) source

Override:

Observable#constructor

Params:

NameTypeAttributeDescription
time Time
peer Peer
invRequestManager InvRequestManager
targetSubscription Subscription
  • optional

Public Members

public get peer: Peer source

public get synced: boolean source

public get syncing: boolean source

Public Methods

public getBlockProof(blockHashToProve: Hash, knownBlock: Block): Promise<Block> source

Params:

NameTypeAttributeDescription
blockHashToProve Hash
knownBlock Block

Return:

Promise<Block>

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

Params:

NameTypeAttributeDescription
address Address

Return:

Promise<Array<TransactionReceipt>>

public getTransactionsProof(block: Block, addresses: Array<Address>): Promise<Array<Transaction>> source

Params:

NameTypeAttributeDescription
block Block
addresses Array<Address>

Return:

Promise<Array<Transaction>>

public knowsBlock(blockHash: Hash): boolean source

Params:

NameTypeAttributeDescription
blockHash Hash

Return:

boolean

public onHeadUpdated() source

public relayBlock(block: Block): boolean source

Params:

NameTypeAttributeDescription
block Block

Return:

boolean

public relayTransaction(transaction: Transaction): boolean source

Params:

NameTypeAttributeDescription
transaction Transaction

Return:

boolean

public removeTransaction(transaction: Transaction) source

Params:

NameTypeAttributeDescription
transaction Transaction

public requestVector(vector: InvVector) source

Params:

NameTypeAttributeDescription
vector InvVector

public subscribe(subscription: Subscription) source

Params:

NameTypeAttributeDescription
subscription Subscription

Protected Methods

protected async __onInv(msg: InvMessage): Promise<void> source

Params:

NameTypeAttributeDescription
msg InvMessage

Return:

Promise<void>

protected _doRequestData(vectors: Array<InvVector>): void source

Params:

NameTypeAttributeDescription
vectors Array<InvVector>

Return:

void

protected abstract _getBlock(hash: Hash, includeForks: boolean, includeBody: boolean): PromiseBlock> source

Params:

NameTypeAttributeDescription
hash Hash
includeForks boolean
  • optional
includeBody boolean
  • optional

Return:

PromiseBlock>

protected abstract _getRawBlock(hash: Hash, includeForks: boolean): PromiseUint8Array> source

Params:

NameTypeAttributeDescription
hash Hash
includeForks boolean
  • optional

Return:

PromiseUint8Array>

protected abstract _getTransaction(hash: Hash): Transaction source

Params:

NameTypeAttributeDescription
hash Hash

Return:

Transaction (nullable: true)

protected _noMoreData(): void source

Return:

void

protected _onAllObjectsProcessed(): void source

Return:

void

protected _onAllObjectsReceived(): void source

Return:

void

protected async _onBlock(msg: BlockMessage): Promise<void> source

Params:

NameTypeAttributeDescription
msg BlockMessage

Return:

Promise<void>

protected _onClose(): void source

Return:

void

protected async _onGetData(msg: GetDataMessage): Promise<void> source

Params:

NameTypeAttributeDescription
msg GetDataMessage

Return:

Promise<void>

protected async _onGetHeader(msg: GetHeaderMessage): Promise source

Params:

NameTypeAttributeDescription
msg GetHeaderMessage

Return:

Promise

protected async _onHeader(msg: HeaderMessage): Promise<void> source

Params:

NameTypeAttributeDescription
msg HeaderMessage

Return:

Promise<void>

protected _onInv(msg: InvMessage): Promise<void> source

Params:

NameTypeAttributeDescription
msg InvMessage

Return:

Promise<void>

protected _onKnownBlockAnnounced(hash: Hash, block: Block): void source

Params:

NameTypeAttributeDescription
hash Hash
block Block

Return:

void

protected _onKnownTransactionAnnounced(hash: Hash, transaction: Transaction): void source

Params:

NameTypeAttributeDescription
hash Hash
transaction Transaction

Return:

void

protected _onNewBlockAnnounced(hash: Hash): void source

Params:

NameTypeAttributeDescription
hash Hash

Return:

void

protected _onNewTransactionAnnounced(hash: Hash): void source

Params:

NameTypeAttributeDescription
hash Hash

Return:

void

protected _onNoUnknownObjects(): void source

Return:

void

protected _onNotFound(msg: NotFoundMessage): void source

Params:

NameTypeAttributeDescription
msg NotFoundMessage

Return:

void

protected _onObjectProcessed(vector: InvVector): void source

Params:

NameTypeAttributeDescription
vector InvVector

Return:

void

protected _onObjectReceived(vector: InvVector): void source

Params:

NameTypeAttributeDescription
vector InvVector

Return:

void

protected _onSubscribe(msg: SubscribeMessage) source

Params:

NameTypeAttributeDescription
msg SubscribeMessage

protected async _onTx(msg: TxMessage): Promise source

Params:

NameTypeAttributeDescription
msg TxMessage

Return:

Promise

protected async _processBlock(hash: Hash, block: Block): Promise<void> source

Params:

NameTypeAttributeDescription
hash Hash
block Block

Return:

Promise<void>

protected async _processHeader(hash: Hash, header: BlockHeader): Promise<void> source

Params:

NameTypeAttributeDescription
hash Hash
header BlockHeader

Return:

Promise<void>

protected async _processTransaction(hash: Hash, transaction: Transaction): Promise<void> source

Params:

NameTypeAttributeDescription
hash Hash
transaction Transaction

Return:

Promise<void>

protected _requestData(): void source

Return:

void

protected _shouldRequestData(vector: InvVector): boolean source

Params:

NameTypeAttributeDescription
vector InvVector

Return:

boolean