コード例 #1
0
ファイル: btcctl.go プロジェクト: RagnarDanneskjold/btcd
// makeSubmitBlock generates the cmd structure for submitblock commands.
func makeSubmitBlock(args []interface{}) (btcjson.Cmd, error) {
	opts := &btcjson.SubmitBlockOptions{}
	if len(args) == 2 {
		opts.WorkID = args[1].(string)
	}

	return btcjson.NewSubmitBlockCmd("btcctl", args[0].(string), opts)
}
コード例 #2
0
ファイル: mining.go プロジェクト: GeertJohan/btcrpcclient
// SubmitBlockAsync returns an instance of a type that can be used to get the
// result of the RPC at some future time by invoking the Receive function on the
// returned instance.
//
// See SubmitBlock for the blocking version and more details.
func (c *Client) SubmitBlockAsync(block *btcutil.Block, options *btcjson.SubmitBlockOptions) FutureSubmitBlockResult {
	blockHex := ""
	if block != nil {
		blockBytes, err := block.Bytes()
		if err != nil {
			return newFutureError(err)
		}

		blockHex = hex.EncodeToString(blockBytes)
	}

	id := c.NextID()
	cmd, err := btcjson.NewSubmitBlockCmd(id, blockHex, options)
	if err != nil {
		return newFutureError(err)
	}

	return c.sendCmd(cmd)
}