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


Golang rpc.HexNumber類代碼示例

本文整理匯總了Golang中github.com/ethereum/go-ethereum/rpc.HexNumber的典型用法代碼示例。如果您正苦於以下問題:Golang HexNumber類的具體用法?Golang HexNumber怎麽用?Golang HexNumber使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: StartRPC

// StartRPC starts the HTTP RPC API server.
func (api *PrivateAdminAPI) StartRPC(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error) {
	api.node.lock.Lock()
	defer api.node.lock.Unlock()

	if api.node.httpHandler != nil {
		return false, fmt.Errorf("HTTP RPC already running on %s", api.node.httpEndpoint)
	}

	if host == nil {
		host = &api.node.httpHost
	}
	if port == nil {
		port = rpc.NewHexNumber(api.node.httpPort)
	}
	if cors == nil {
		cors = &api.node.httpCors
	}

	modules := api.node.httpWhitelist
	if apis != nil {
		modules = nil
		for _, m := range strings.Split(*apis, ",") {
			modules = append(modules, strings.TrimSpace(m))
		}
	}

	if err := api.node.startHTTP(fmt.Sprintf("%s:%d", *host, port.Int()), api.node.rpcAPIs, modules, *cors); err != nil {
		return false, err
	}
	return true, nil
}
開發者ID:etherapis,項目名稱:etherapis,代碼行數:32,代碼來源:api.go

示例2: StartWS

// StartWS starts the websocket RPC API server.
func (api *PrivateAdminAPI) StartWS(host *string, port *rpc.HexNumber, allowedOrigins *string, apis *string) (bool, error) {
	api.node.lock.Lock()
	defer api.node.lock.Unlock()

	if api.node.wsHandler != nil {
		return false, fmt.Errorf("WebSocket RPC already running on %s", api.node.wsEndpoint)
	}

	if host == nil {
		host = &api.node.wsHost
	}
	if port == nil {
		port = rpc.NewHexNumber(api.node.wsPort)
	}
	if allowedOrigins == nil {
		allowedOrigins = &api.node.wsOrigins
	}

	modules := api.node.wsWhitelist
	if apis != nil {
		modules = nil
		for _, m := range strings.Split(*apis, ",") {
			modules = append(modules, strings.TrimSpace(m))
		}
	}

	if err := api.node.startWS(fmt.Sprintf("%s:%d", *host, port.Int()), api.node.rpcAPIs, modules, *allowedOrigins); err != nil {
		return false, err
	}
	return true, nil
}
開發者ID:etherapis,項目名稱:etherapis,代碼行數:32,代碼來源:api.go

示例3: UninstallFilter

// UninstallFilter disables and removes an existing filter.
func (s *PublicWhisperAPI) UninstallFilter(filterId rpc.HexNumber) bool {
	s.messagesMu.Lock()
	defer s.messagesMu.Unlock()

	if _, ok := s.messages[filterId.Int()]; ok {
		delete(s.messages, filterId.Int())
		return true
	}
	return false
}
開發者ID:Codzart,項目名稱:go-ethereum,代碼行數:11,代碼來源:api.go

示例4: GetFilterChanges

// GetFilterChanges retrieves all the new messages matched by a filter since the last retrieval.
func (s *PublicWhisperAPI) GetFilterChanges(filterId rpc.HexNumber) []WhisperMessage {
	s.messagesMu.RLock()
	defer s.messagesMu.RUnlock()

	if s.messages[filterId.Int()] != nil {
		if changes := s.messages[filterId.Int()].retrieve(); changes != nil {
			return changes
		}
	}
	return returnWhisperMessages(nil)
}
開發者ID:Codzart,項目名稱:go-ethereum,代碼行數:12,代碼來源:api.go

示例5: GetMessages

// GetMessages retrieves all the known messages that match a specific filter.
func (s *PublicWhisperAPI) GetMessages(filterId rpc.HexNumber) []WhisperMessage {
	// Retrieve all the cached messages matching a specific, existing filter
	s.messagesMu.RLock()
	defer s.messagesMu.RUnlock()

	var messages []*Message
	if s.messages[filterId.Int()] != nil {
		messages = s.messages[filterId.Int()].messages()
	}

	return returnWhisperMessages(messages)
}
開發者ID:Codzart,項目名稱:go-ethereum,代碼行數:13,代碼來源:api.go


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