當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.NotifyBlocks方法代碼示例

本文整理匯總了Golang中github.com/decred/dcrrpcclient.Client.NotifyBlocks方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.NotifyBlocks方法的具體用法?Golang Client.NotifyBlocks怎麽用?Golang Client.NotifyBlocks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/decred/dcrrpcclient.Client的用法示例。


在下文中一共展示了Client.NotifyBlocks方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: connectRPCClient

// connectRPCClient attempts to establish an RPC connection to the created
// dcrd process belonging to this Harness instance. If the initial connection
// attempt fails, this function will retry h.maxConnRetries times, backing off
// the time between subsequent attempts. If after h.maxConnRetries attempts,
// we're not able to establish a connection, this function returns with an error.
func (h *Harness) connectRPCClient() error {
	var client *rpc.Client
	var err error

	rpcConf := h.node.config.rpcConnConfig()
	for i := 0; i < h.maxConnRetries; i++ {
		if client, err = rpc.New(&rpcConf, h.handlers); err != nil {
			time.Sleep(time.Duration(math.Log(float64(i+3))) * 50 * time.Millisecond)
			continue
		}
		break
	}

	if client == nil {
		return fmt.Errorf("connection timed out: %v", err)
	}

	err = client.NotifyBlocks()
	if err != nil {
		return err
	}

	h.Node = client
	return nil
}
開發者ID:decred,項目名稱:dcrwallet,代碼行數:30,代碼來源:rpcharness.go


注:本文中的github.com/decred/dcrrpcclient.Client.NotifyBlocks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。