区块链服务于虚拟货币,区块链技术用个体自己算哈希数来进行货币发行,通过加密技术支持帐户交易,通过分布式通信进行全节点账本同步,提供架构来支持钱包等高级功能 。它的出现再次证明计算机和互联网是强大工具,实体世界里的行业模型可以很好地在计算机世界里体现。
锐英源研究过区块链平台多个源代码版本,各个版本都进行了定制开发,客户满意,平台可靠稳定运行。这里分享2个方面的知识点:编译和参数。
区块链源代码编译
区块链是开源的,一般也是用开源的操作系统,现在经常用ubuntu来当区块链的运行平台。在ubuntu下正常的编译步骤如下:
sudo apt-get update sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
sudo apt-get install libboost-all-dev
sudo apt-get install git
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update sudo apt-get install libdb4.8-dev libdb4.8++-dev
./autogen.sh
./configure
make
在ubuntu12下,这些步骤没问题。但是到ubuntu14下,在处理libdb4.8行时,会提示找不到libdb,这时候不要慌,把libdb4.8去掉,变成如下行就可以:
sudo apt-get install libdb4.8++-dev
安装源在识别时,不能用libdb4.8-dev来找到包,但是用后者就可以,后者也包含libdb4.8-dev,安装后也可以编译出来区块链的可执行文件。这事件的原因就是开源的不全面性造成的,开源世界里遇到变化是常事。
另外要注意操作系统平台的32位或64位情况,一般是用64位平台操作系统才可以运行。
参数
Configuring a blockchain
The parameters of a blockchain are configured after creating the chain by running multichain-util create [chain-name], and before starting the chain by running multichaind [chain-name].
Parameters are set in the params.dat file for each blockchain, which can be modified in any text editor. Once the blockchain is initialized, these parameters cannot be changed. To prevent accidental modification, a hash of the parameters is added to params.dat when the chain starts running. multichain-util create [chain-name]创建区块链后,参数会配置上。
When new nodes attempt to connect to an existing blockchain, they first download a minimal set of blockchain parameters from the existing node, and write them to the params.dat file in the appropriate directory. Once they are granted permission to connect, they are able to download the full set of blockchain parameters.新节点想连接存在的区块链,必须先下载已创建区块链节点机器好的区块链参数。
The parameters for a blockchain can be retrieved using the getblockchainparams API call. getblockchainparams 命令可以查看参数。
Full list of blockchain parameters
Below is a full list of parameters in the params.dat file, grouped by section.
Basic chain parameters
Parameter
|
Description
|
Example
|
chain-protocol
|
Use multichain for a MultiChain blockchain or bitcoin for a bitcoin-style blockchain with no permissions, native assets or streams.
|
multichain
|
chain-description
|
Textual description of the blockchain for display to users.
|
Internal chain
|
root-stream-name
|
Name of the root stream for general data storage (leave blank for none).
|
root
|
root-stream-open
|
Allow anyone with send permissions to write to the root stream.
|
true
|
chain-is-testnet
|
Whether to set testnet to true in the output of various JSON-RPC API calls. This is for compatibility with Bitcoin Core and does not affect any other testnet-like behavior.
|
false
|
target-block-time
|
Target average number of seconds between blocks, i.e. delay for confirming transactions. If this is below 10 seconds, it is recommended to set mining-turnover low, to minimize the number of forks.
|
60 (one minute)
|
maximum-block-size
|
Maximum number of bytes in each block, to prevent network flooding by a rogue miner.
|
1000000 (1MB)
|
Global permissions
Parameter
|
Description
|
Example
|
anyone-can-connect
|
Apply no restriction to connecting to the network, i.e. nodes do not require connect permissions.
|
false
|
anyone-can-send
|
Apply no restriction to sending transactions, i.e. signing transaction inputs.
|
false
|
anyone-can-receive
|
Apply no restriction to receiving transactions, i.e. appearing in transaction outputs.
|
false
|
anyone-can-receive-empty
|
Apply no restriction to addresses which appear in transaction outputs containing no native currency, assets or other metadata. Only relevant if anyone-can-receive=false. This allows addresses without receivepermission to include a change output in non-asset transactions, e.g. to publish to streams.
|
true
|
anyone-can-create
|
Apply no restriction to creating new streams.
|
false
|
anyone-can-issue
|
Apply no restriction to issuing (creating) new native assets.
|
false
|
anyone-can-mine
|
Apply no restriction to mining blocks for the chain, i.e. confirming transactions.
|
false
|
anyone-can-activate
|
Apply no restriction to changing connect, send and receive permissions of other users.
|
false
|
anyone-can-admin
|
Apply no restriction to changing all permissions of other users.
|
false
|
support-miner-precheck
|
Support advanced miner permission checks by caching the inputs spent by an administrator when setting admin or mine permissions – see permissions management for more information.
|
true
|
allow-p2sh-outputs
|
Allow pay to scripthash outputs, where the redeem script is only revealed when an output is spent. See permissions management for more information about permissions and P2SH addresses.
|
true
|
allow-multisig-outputs
|
Allow multisignature outputs, where more than one address is explicitly listed in a transaction output, and a given number of these addresses are required to sign in order to spend that output. See permissions management for more information about permissions and multisig outputs.
|
true
|
免费源码
|