Mining 命令
Mining 命令用于和挖矿相关的操作。指定节点生成区块模版用于挖矿,获取挖矿信息,获取挖矿状态等。
可以使用mvc-cli help command
来查看具体命令的使用方法。JsonRpc调用方法在示例中。
命令列表
命令列表如下(从文档右侧边框选取对应的命令进行查看):
== Mining ==
getblocktemplate ( TemplateRequest )
getminingcandidate coinbase (optional, default false)
getmininginfo
getnetworkhashps ( nblocks height )
prioritisetransaction <txid> <priority delta> <fee delta>
submitblock "hexdata" ( "jsonparametersobject" )
submitminingsolution "<json string>"
verifyblockcandidate "hexdata" ( "jsonparametersobject" )
getblocktemplate
生成标准区块模板(同比特币)。
getblocktemplate ( TemplateRequest )
If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.
It returns data needed to construct a block to work on.
For full specification, see BIPs 22, 23, 9, and 145:
https://github.com/mvc/bips/blob/master/bip-0022.mediawiki
https://github.com/mvc/bips/blob/master/bip-0023.mediawiki
https://github.com/mvc/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes
https://github.com/mvc/bips/blob/master/bip-0145.mediawiki
Arguments:
1. template_request (json object, optional) A json object in the following spec
{
"mode":"template" (string, optional) This must be set to "template", "proposal" (see BIP 23), or omitted
"capabilities":[ (array, optional) A list of strings
"support" (string) client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'
,...
]
}
Result:
{
"version" : n, (numeric) The preferred block version
"previousblockhash" : "xxxx", (string) The hash of current highest block
"transactions" : [ (array) contents of non-coinbase transactions that should be included in the next block
{
"data" : "xxxx", (string) transaction data encoded in hexadecimal (byte-for-byte)
"txid" : "xxxx", (string) transaction id encoded in little-endian hexadecimal
"hash" : "xxxx", (string) hash encoded in little-endian hexadecimal (including witness data)
"depends" : [ (array) array of numbers
n (numeric) transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is
,...
],
"fee": n, (numeric) difference in value between transaction inputs and outputs (in Satoshis); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one
"required" : true|false (boolean) if provided and true, this transaction must be in the final block
}
,...
],
"coinbaseaux" : { (json object) data that should be included in the coinbase's scriptSig content
"flags" : "xx" (string) key name is to be ignored, and value included in scriptSig
},
"coinbasevalue" : n, (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in Satoshis)
"coinbasetxn" : { ... }, (json object) information for coinbase transaction
"target" : "xxxx", (string) The hash target
"mintime" : xxx, (numeric) The minimum timestamp appropriate for next block time in seconds since epoch (Jan 1 1970 GMT)
"mutable" : [ (array of string) list of ways the block template may be changed
"value" (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'
,...
],
"noncerange" : "00000000ffffffff",(string) A range of valid nonces
"sizelimit" : n, (numeric) limit of block size
"curtime" : ttt, (numeric) current timestamp in seconds since epoch (Jan 1 1970 GMT)
"bits" : "xxxxxxxx", (string) compressed target of next block
"height" : n (numeric) The height of the next block
}
Examples:
> mvc-cli getblocktemplate
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblocktemplate", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:9882/
getminingcandidate
使用mining candidate协议获取挖矿候选区块。
getminingcandidate coinbase (optional, default false)
Returns Mining-Candidate protocol data.
Arguments:
1. "coinbase" (boolean, optional) True if a coinbase transaction is required in result
Result: (json string)
{
"id": n, (string) Candidate identifier for submitminingsolution
"prevhash": "xxxx", (hex string) Hash of the previous block
"coinbase": "xxxx", (optional hex string encoded binary transaction) Coinbase transaction
"coinbaseValue": n, (integer) Total funds available for the coinbase transaction (in Satoshis)
"version": n, (integer) Block version
"nBits": "xxxx", (hex string) Difficulty
"time": n, (integer) Block time
"height": n, (integer) Current Block Height
"num_tx": n, (integer) Number of transactions the current candidate has including coinbase transaction
"sizeWithoutCoinbase": n, (integer) Size of current block candidate in bytes without coinbase transaction
"merkleProof": [ (list of hex strings) Merkle branch for the block
xxxx,
yyyy,
]
}