Home Reference Source
public class | source

InterfaceBlockchain

Extends:

InterfaceBlockchainBasic → InterfaceBlockchain

Blockchain contains a chain of blocks based on Proof of Work

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

Method Summary

Public Methods
public
public

getBlock(height: *): *

public

getDifficultyTarget(height: *): *

public

getHashPrev(height: *): *

public

getTimeStamp(height: *): *

public

async includeBlockchainBlock(block: *, resetMining: *, socketsAvoidBroadcast: *): Promise<boolean>

Include a new block at the end of the blockchain, by validating the next block Will save the block in the blockchain, if it is valid

public

async removeBlockchain(index: *, removeFiles: boolean): boolean

public

async saveBlockchain(startingHeight: *, endingHeight: *): boolean

public

Save Blockchain when the application was terminated

public

async saveNewBlock(block: *, saveLength: boolean, saveInfinitum: boolean): boolean

public

async simulateNewBlock(block: *, revertAutomatically: *, revertActions: *, callback: *, showUpdate: boolean): *

public
public

async validateBlockchainBlock(block: *, prevDifficultyTarget: *, prevHash: *, prevTimeStamp: *, blockValidationType: *): Promise<boolean>

Validate the block, but the Block WAS NOT ADDED in the blockchain array

Private Methods
private

async _blockIncluded(block: *)

private

_getLoadBlockchainValidationType(indexStart: *, i: *, numBlocks: *, indexStartProcessingOffset: *): *

private

async _loadBlock(indexStart: *, i: *, blockValidation: *): *

private

async _loadBlockchain(indexStartLoadingOffset: *, indexStartProcessingOffset: *, numBlocks: *): *

private

_onBlockCreated(block: *, saveBlock: *)

Event fired when a new Block has been inserted in the blockchain

Inherited Summary

From class InterfaceBlockchainBasic
public

agent: *

public
public

blocks: *

public

db: *

public
public

mining: *

public
public
public
public
public
private
private
public

async loadBlockchain(): *

public

sleep(ms: *): *

public

toJSON()

public
private
private
private

_setAgent(newAgent: *)

Public Constructors

public constructor() source

Override:

InterfaceBlockchainBasic#constructor

Public Members

public freeMemory: * source

public hardForks: * source

Public Methods

public createBlockValidation(): * source

Return:

*

public getBlock(height: *): * source

Params:

NameTypeAttributeDescription
height *

Return:

*

public getDifficultyTarget(height: *): * source

Params:

NameTypeAttributeDescription
height *

Return:

*

public getHashPrev(height: *): * source

Params:

NameTypeAttributeDescription
height *

Return:

*

public getTimeStamp(height: *): * source

Params:

NameTypeAttributeDescription
height *

Return:

*

public async includeBlockchainBlock(block: *, resetMining: *, socketsAvoidBroadcast: *): Promise<boolean> source

Include a new block at the end of the blockchain, by validating the next block Will save the block in the blockchain, if it is valid

Params:

NameTypeAttributeDescription
block *
resetMining *
socketsAvoidBroadcast *

Return:

Promise<boolean>

public async removeBlockchain(index: *, removeFiles: boolean): boolean source

Params:

NameTypeAttributeDescription
index *
removeFiles boolean
  • optional
  • default: true

Return:

boolean

public async saveBlockchain(startingHeight: *, endingHeight: *): boolean source

Params:

NameTypeAttributeDescription
startingHeight *
endingHeight *

Return:

boolean

public async saveBlockchainTerminated(): Promise<boolean> source

Save Blockchain when the application was terminated

Return:

Promise<boolean>

public async saveNewBlock(block: *, saveLength: boolean, saveInfinitum: boolean): boolean source

Params:

NameTypeAttributeDescription
block *
saveLength boolean
  • optional
  • default: false
saveInfinitum boolean
  • optional
  • default: false

Return:

boolean

public async simulateNewBlock(block: *, revertAutomatically: *, revertActions: *, callback: *, showUpdate: boolean): * source

Params:

NameTypeAttributeDescription
block *
revertAutomatically *
revertActions *
callback *
showUpdate boolean
  • optional
  • default: true

Return:

*

public async validateBlockchain(): boolean source

Return:

boolean

public async validateBlockchainBlock(block: *, prevDifficultyTarget: *, prevHash: *, prevTimeStamp: *, blockValidationType: *): Promise<boolean> source

Validate the block, but the Block WAS NOT ADDED in the blockchain array

Params:

NameTypeAttributeDescription
block *
prevDifficultyTarget *
prevHash *
prevTimeStamp *
blockValidationType *

Return:

Promise<boolean>

Private Methods

private async _blockIncluded(block: *) source

Params:

NameTypeAttributeDescription
block *

private _getLoadBlockchainValidationType(indexStart: *, i: *, numBlocks: *, indexStartProcessingOffset: *): * source

Params:

NameTypeAttributeDescription
indexStart *
i *
numBlocks *
indexStartProcessingOffset *

Return:

*

private async _loadBlock(indexStart: *, i: *, blockValidation: *): * source

Params:

NameTypeAttributeDescription
indexStart *
i *
blockValidation *

Return:

*

private async _loadBlockchain(indexStartLoadingOffset: *, indexStartProcessingOffset: *, numBlocks: *): * source

Override:

InterfaceBlockchainBasic#_loadBlockchain

Params:

NameTypeAttributeDescription
indexStartLoadingOffset *
  • optional
  • default: undefined
indexStartProcessingOffset *
  • optional
  • default: undefined
numBlocks *

Return:

*

private _onBlockCreated(block: *, saveBlock: *) source

Event fired when a new Block has been inserted in the blockchain

Params:

NameTypeAttributeDescription
block *
saveBlock *