Home Reference Source
public class | source

InterfaceBlockchainFork

Blockchain contains a chain of blocks based on Proof of Work

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public
public

forkBlocks: *[]

public
public
public
public
public

forkId: *

public
public
public
public
public
public

headers: *[]

public

sockets: *[]

public
Private Members
private
private

Method Summary

Public Methods
public
public
public

getForkBlock(height: *): *

public

getForkDifficultyTarget(height: *): *

public

getForkPrevHash(height: *): *

public

getForkSocket(index: *): *

public

getForkTimeStamp(height: *): *

public

getSocket(): *

public

async includeForkBlock(block: *): boolean

public

initializeConstructor(blockchain: *, forkId: *, sockets: *, forkStartingHeight: *, forkChainStartingPoint: *, forkChainLength: *, forkChainWork: *, headers: *, forkReady: boolean)

initializeConstructor is used to initialize the constructor dynamically using .apply method externally passing the arguments

public
public

postFork(forkedSuccessfully: *)

public

postForkTransactions(forkedSuccessfully: *)

public

preFork(revertActions: *)

public

preForkClone(cloneBlocks: boolean): boolean

public

printException(exception: *)

public

pushHeader(hash: *)

public

pushHeaders(hashes: *)

public

pushSocket(socket: *, priority: *): *

public

async revertFork()

public

async saveFork(): *

Validate the Fork and Use the fork as main blockchain

public

async saveIncludeBlock(index: *, revertActions: *, saveBlock: boolean, showUpdate: boolean): boolean

public

sleep(ms: *): *

public

toJSON(): {"forkReady": *, "forkStartingHeightDownloading": *, "forkChainStartingPoint": *, "forkChainLength": *, "forkBlocks": *, "forkHeaders": *}

public
Private Methods
private

_createBlockValidation_BlockchainValidation(height: *, forkHeight: *): *

private

_createBlockValidation_ForkValidation(height: *, forkHeight: *): *

private
private

_findSocket(socket: *): *

private
private

async _validateFork(validateHashesAgain: *, firstValidation: *): boolean

private

async _validateForkBlock(block: *, height: *): *

It Will only validate the hashes of the Fork Blocks

Public Constructors

public constructor() source

Public Members

public blockchain: * source

public downloadAllBlocks: boolean source

public downloadBlocksSleep: boolean source

public forkBlocks: *[] source

public forkChainLength: * source

public forkChainStartingPoint: * source

public forkChainWork: * source

public forkHeaders: * source

public forkId: * source

public forkIsSaving: boolean source

public forkPromise: *[] source

public forkReady: boolean source

public forkStartingHeight: * source

public forkStartingHeightDownloading: * source

public headers: *[] source

public sockets: *[] source

public socketsFirst: * source

Private Members

private _blocksCopy: *[] source

private _forkPromiseResolver: * source

Public Methods

public deleteAlreadyIncludedBlocks(): boolean source

Return:

boolean

public destroyFork() source

public getForkBlock(height: *): * source

Params:

NameTypeAttributeDescription
height *

Return:

*

public getForkDifficultyTarget(height: *): * source

Params:

NameTypeAttributeDescription
height *

Return:

*

public getForkPrevHash(height: *): * source

Params:

NameTypeAttributeDescription
height *

Return:

*

public getForkSocket(index: *): * source

Params:

NameTypeAttributeDescription
index *

Return:

*

public getForkTimeStamp(height: *): * source

Params:

NameTypeAttributeDescription
height *

Return:

*

public getSocket(): * source

Return:

*

public async includeForkBlock(block: *): boolean source

Params:

NameTypeAttributeDescription
block *

Return:

boolean

public initializeConstructor(blockchain: *, forkId: *, sockets: *, forkStartingHeight: *, forkChainStartingPoint: *, forkChainLength: *, forkChainWork: *, headers: *, forkReady: boolean) source

initializeConstructor is used to initialize the constructor dynamically using .apply method externally passing the arguments

Params:

NameTypeAttributeDescription
blockchain *
forkId *
sockets *
forkStartingHeight *
forkChainStartingPoint *
forkChainLength *
forkChainWork *
headers *
forkReady boolean
  • optional
  • default: false

public initializeFork(): boolean source

Return:

boolean

public postFork(forkedSuccessfully: *) source

Params:

NameTypeAttributeDescription
forkedSuccessfully *

public postForkTransactions(forkedSuccessfully: *) source

Params:

NameTypeAttributeDescription
forkedSuccessfully *

public preFork(revertActions: *) source

Params:

NameTypeAttributeDescription
revertActions *

public preForkClone(cloneBlocks: boolean): boolean source

Params:

NameTypeAttributeDescription
cloneBlocks boolean
  • optional
  • default: true

Return:

boolean

public printException(exception: *) source

Params:

NameTypeAttributeDescription
exception *

public pushHeader(hash: *) source

Params:

NameTypeAttributeDescription
hash *

public pushHeaders(hashes: *) source

Params:

NameTypeAttributeDescription
hashes *

public pushSocket(socket: *, priority: *): * source

Params:

NameTypeAttributeDescription
socket *
priority *

Return:

*

public async revertFork() source

public async saveFork(): * source

Validate the Fork and Use the fork as main blockchain

overwrite the blockchain blocks with the forkBlocks

Return:

*

public async saveIncludeBlock(index: *, revertActions: *, saveBlock: boolean, showUpdate: boolean): boolean source

Params:

NameTypeAttributeDescription
index *
revertActions *
saveBlock boolean
  • optional
  • default: false
showUpdate boolean
  • optional
  • default: false

Return:

boolean

public sleep(ms: *): * source

Params:

NameTypeAttributeDescription
ms *

Return:

*

public toJSON(): {"forkReady": *, "forkStartingHeightDownloading": *, "forkChainStartingPoint": *, "forkChainLength": *, "forkBlocks": *, "forkHeaders": *} source

Return:

{"forkReady": *, "forkStartingHeightDownloading": *, "forkChainStartingPoint": *, "forkChainLength": *, "forkBlocks": *, "forkHeaders": *}

public validateForkImmutability(): boolean source

Return:

boolean

Private Methods

private _createBlockValidation_BlockchainValidation(height: *, forkHeight: *): * source

Params:

NameTypeAttributeDescription
height *
forkHeight *

Return:

*

private _createBlockValidation_ForkValidation(height: *, forkHeight: *): * source

Params:

NameTypeAttributeDescription
height *
forkHeight *

Return:

*

private _deleteBackupBlocks() source

private _findSocket(socket: *): * source

Params:

NameTypeAttributeDescription
socket *

Return:

*

private _validateChainWork() source

private async _validateFork(validateHashesAgain: *, firstValidation: *): boolean source

Params:

NameTypeAttributeDescription
validateHashesAgain *
firstValidation *

Return:

boolean

private async _validateForkBlock(block: *, height: *): * source

It Will only validate the hashes of the Fork Blocks

Params:

NameTypeAttributeDescription
block *
height *

Return:

*