Documentation

Block
in

内区块链 Block

服务端内部区块链数据支持

默认在插入新块的时候会进行插入锁、插入结束(成功或失败)解锁。 如果希望不影响其他部分性能、Redis服务器应该指定一个独立数据库处理。 不支持Redis时自动使用MySQL数据库、采用插入锁表的方式。

考虑到区块链本身的实时性要求很高、所以应当采用Redis主、MySQL辅(备份)的方式。 其中Redis主数据库集中维护实时数据提交和计算。 MySQL数据库作为一个定时的数据备份,这样避免了MySQL锁的性能瓶颈,通过异步机制或队列管道进行数据的备份。 其中长期不被读取的数据可以从Redis服务器中删除、节省内存空间。

Server internal blockchain data support

Lock inserts when insert a new block by default, and unlock at the end of the insert done (success or failure). If you want to not affect other parts of the performance, you should specify a separate Redis database for processing.  * Automatically use MySQL database when Redis is not supported, and lock write when insert block.

Considering the high real-time requirements of the blockchain itself, you should use the Redis master and MySql assistant (backup). The Redis master database centrally maintains real-time data submission and calculations. MySQL database as a timed data backup, this avoids the performance bottleneck of MySQL lock, data backup through asynchronous mechanism or queue pipeline. Data that has not been read for a long time can be deleted from the Redis server, saving memory space.

Table of Contents

$data
$index
$timestamp
$hash
__construct() Block constructor. mixed
add() 新块 new block Block
generateHash() 生成哈希 generateHash string
encode() 转义 encode bool|string
getId() mixed
getHash() mixed

Properties

$timestamp

private mixed $timestamp

Methods

__construct()

Block constructor.

public __construct( $data : mixed [, $index : int = 1 ] [, $timestamp : int|null = null ] [, $hash : string|null = null ] ) : mixed
Parameters
$data : mixed

数据

$index : int = 1

索引id

$timestamp : int|null = null

时间戳

$hash : string|null = null

前块哈希

Return values
mixed

add()

新块 new block

public add( $data : ) : Block
Parameters
$data :
Return values
Block

generateHash()

生成哈希 generateHash

public generateHash( ) : string
Return values
string

encode()

转义 encode

public encode( ) : bool|string
Return values
bool|string

getId()

public getId( ) : mixed
Return values
mixed

getHash()

public getHash( ) : mixed
Return values
mixed

Search results