Home Reference Source
public class | source

InterfaceBlockchainBlock

Static Method Summary

Static Public Methods
public static

async computeHashStatic(newNonce: *, height: *, difficultyTargetPrev: *, computedBlockPrefix: *, blockNonce: *): Promise<Buffer>

Computes a hash based on static block data

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public
public

data: *

public

db: *

public
public get
public

hash: *

public get
public

height: *

public

nonce: *

public

reward: *

public get
public set
public
public

version: *

public get
Private Members
private
private
private
private

Method Summary

Public Methods
public

async computeHash(newNonce: *): Promise<Buffer>

Computes block's hash

public

deserializeBlock(buffer: *, height: *, reward: *, difficultyTargetPrev: *, offset: number, blockLengthValidation: boolean, usePrevHash: boolean): *

public
public

equals(targetBlock: *): *

public

getBlockHeader(): {"version": *, "height": *, "hash": *, "hashPrev": *, "data": *, "nonce": *, "timeStamp": *, "difficultyTargetPrev": *}

public

getBlockHeaderWithInformation(): {"height": *, "chainLength": *, "chainStartingPoint": *, "header": *}

public

async importBlockFromHeader(json: *)

public

async loadBlock(): boolean

public

async removeBlock(): *

public

async saveBlock(): *

public

serializeBlock(requestHeader: *): *

public

toJSON(): {"height": *, "version": *, "hashPrev": *, "data": *, "nonce": *, "timeStamp": *, "difficulty": *}

public

toString(): *

public

async validateBlock(height: *): boolean

Private Methods
private

_computeBlockHeaderPrefix(skipPrefix: *, requestHeader: *): *

private
private

it will recheck the validity of the block

private
private

_validateMedianTimestamp(timestamp: *)

private

Static Public Methods

public static async computeHashStatic(newNonce: *, height: *, difficultyTargetPrev: *, computedBlockPrefix: *, blockNonce: *): Promise<Buffer> source

Computes a hash based on static block data

Params:

NameTypeAttributeDescription
newNonce *
height *
difficultyTargetPrev *
computedBlockPrefix *
blockNonce *

Return:

Promise<Buffer>

Public Constructors

public constructor() source

Public Members

public blockValidation: * source

public blockchain: * source

public computedBlockPrefix: * source

public data: * source

public db: * source

public difficultyTarget: * source

public get difficultyTargetPrev: * source

public hash: * source

public get hashPrev: * source

public height: * source

public nonce: * source

public reward: * source

public get socketPropagatedBy: * source

public set socketPropagatedBy source

public timeStamp: * source

public version: * source

public get workDone: * source

Private Members

private _difficultyTargetPrev: * source

private _hashPrev: * source

private _socketPropagatedBy: * source

private _workDone: * source

Public Methods

public async computeHash(newNonce: *): Promise<Buffer> source

Computes block's hash

Params:

NameTypeAttributeDescription
newNonce *

Return:

Promise<Buffer>

public deserializeBlock(buffer: *, height: *, reward: *, difficultyTargetPrev: *, offset: number, blockLengthValidation: boolean, usePrevHash: boolean): * source

Params:

NameTypeAttributeDescription
buffer *
height *
reward *
difficultyTargetPrev *
offset number
  • optional
  • default: 0
blockLengthValidation boolean
  • optional
  • default: true
usePrevHash boolean
  • optional
  • default: false

Return:

*

public destroyBlock() source

public equals(targetBlock: *): * source

Params:

NameTypeAttributeDescription
targetBlock *

Return:

*

public getBlockHeader(): {"version": *, "height": *, "hash": *, "hashPrev": *, "data": *, "nonce": *, "timeStamp": *, "difficultyTargetPrev": *} source

Return:

{"version": *, "height": *, "hash": *, "hashPrev": *, "data": *, "nonce": *, "timeStamp": *, "difficultyTargetPrev": *}

public getBlockHeaderWithInformation(): {"height": *, "chainLength": *, "chainStartingPoint": *, "header": *} source

Return:

{"height": *, "chainLength": *, "chainStartingPoint": *, "header": *}

public async importBlockFromHeader(json: *) source

Params:

NameTypeAttributeDescription
json *

public async loadBlock(): boolean source

Return:

boolean

public async removeBlock(): * source

Return:

*

public async saveBlock(): * source

Return:

*

public serializeBlock(requestHeader: *): * source

Params:

NameTypeAttributeDescription
requestHeader *

Return:

*

public toJSON(): {"height": *, "version": *, "hashPrev": *, "data": *, "nonce": *, "timeStamp": *, "difficulty": *} source

Return:

{"height": *, "version": *, "hashPrev": *, "data": *, "nonce": *, "timeStamp": *, "difficulty": *}

public toString(): * source

Return:

*

public async validateBlock(height: *): boolean source

Params:

NameTypeAttributeDescription
height *

Return:

boolean

Private Methods

private _computeBlockHeaderPrefix(skipPrefix: *, requestHeader: *): * source

Params:

NameTypeAttributeDescription
skipPrefix *
requestHeader *

Return:

*

private async _supplementaryValidation(): boolean source

Return:

boolean

private async _validateBlockHash(): boolean source

it will recheck the validity of the block

Return:

boolean

private _validateBlockTimeStamp() source

private _validateMedianTimestamp(timestamp: *) source

Params:

NameTypeAttributeDescription
timestamp *

private _validateTargetDifficulty(): boolean source

Return:

boolean