Block

Implements \JsonSerializable, \RKD\Blockchain\Contracts\Arrayable, \RKD\Blockchain\Contracts\Comparable

Block class

author

Rene Korss rene.korss@gmail.com

package

Default

Methods

Constructor

__construct(\RKD\Blockchain\Block $previousBlock, string $data) : void

Arguments

$previousBlock

\RKD\Blockchain\Block

Previous block in chain

$data

string

Data to store in block

Compare Block to another for equalness

compare(mixed $compare) : boolean

Arguments

$compare

mixed

Comparable object

Response

boolean

Generate hash for block

generateHash() : string

Response

string

Generated hash

Generate genesis block

genesis(string $data = 'Genesis block') : self
static

Arguments

$data

string

Data to store in block

Response

self

Get block data

getData() : string

Response

string

Block data

Get block hash

getHash() : string

Response

string

Block hash

Get block index

getIndex() : integer

Response

integer

Block index

Get previous block hash

getPreviousHash() : string

Response

string

Previous block hash

Detect if block is valid

isValid() : boolean

Response

boolean

True if block is valid, false otherwise

Get block as array

toArray() : array

Response

array

Properties

Block index

index : integer
var

Type(s)

integer

Block hash

hash : string
var

Type(s)

string

Previous block hash

previousHash : string
var

Type(s)

string

Block creation date and time

createdDatetime : \DateTimeImmutable
var

Type(s)

\DateTimeImmutable

Block data

data : string
var

Type(s)

string

Previous block

previousBlock : \RKD\Blockchain\Block
var

Type(s)

\RKD\Blockchain\Block