Documentation ¶
Overview ¶
Copyright 2020 ChainSafe Systems (ON) Corp. This file is part of gossamer.
The gossamer library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The gossamer library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the gossamer library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2020 ChainSafe Systems (ON) Corp. This file is part of gossamer.
The gossamer library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The gossamer library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the gossamer library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
Constants ¶
const ( SUB_NEW_HEAD = iota SUB_FINALIZED_HEAD SUB_STORAGE )
consts to represent subscription type
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DotUpCodec ¶
type DotUpCodec struct{}
DotUpCodec for overridding default jsonCodec
func NewDotUpCodec ¶
func NewDotUpCodec() *DotUpCodec
NewDotUpCodec for creating instance of DocUpCodec
func (*DotUpCodec) NewRequest ¶
func (c *DotUpCodec) NewRequest(r *http.Request) rpc.CodecRequest
NewRequest is overridden to inject our codec handler
type DotUpCodecRequest ¶
type DotUpCodecRequest struct {
*json2.CodecRequest
}
DotUpCodecRequest decodes and encodes a single request. UpCodecRequest implements gorilla/rpc.CodecRequest interface primarily by embedding the CodecRequest from gorilla/rpc/json. By selectively adding CodecRequest methods to UpCodecRequest, we can modify that behavior while maintaining all the other remaining CodecRequest methods from gorilla's rpc/json implementation
func (*DotUpCodecRequest) Method ¶
func (c *DotUpCodecRequest) Method() (string, error)
Method returns the decoded method as a string of the form "Service.Method" after checking for, and correcting a underscore and lowercase method name By being of lower depth in the struct , Method will replace the implementation of Method() on the embedded CodecRequest. Because the request data is part of the embedded json.CodecRequest, and unexported, we have to get the requested method name via the embedded CR's own method Method(). Essentially, this just intercepts the return value from the embedded gorilla/rpc/json.CodecRequest.Method(), checks/modifies it, and passes it on to the calling rpc server.
type ErrorMessageJSON ¶
ErrorMessageJSON json for error messages
type ErrorResponseJSON ¶
type ErrorResponseJSON struct { Jsonrpc string `json:"jsonrpc"` Error *ErrorMessageJSON `json:"error"` ID *big.Int `json:"id"` }
ErrorResponseJSON json for error responses
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer gateway for RPC server
func NewHTTPServer ¶
func NewHTTPServer(cfg *HTTPServerConfig) *HTTPServer
NewHTTPServer creates a new http server and registers an associated rpc server
func (*HTTPServer) RegisterModules ¶
func (h *HTTPServer) RegisterModules(mods []string)
RegisterModules registers the RPC services associated with the given API modules
func (*HTTPServer) ServeHTTP ¶
func (h *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implemented to handle WebSocket connections
func (*HTTPServer) Start ¶
func (h *HTTPServer) Start() error
Start registers the rpc handler function and starts the rpc http and websocket server
type HTTPServerConfig ¶
type HTTPServerConfig struct { BlockAPI modules.BlockAPI StorageAPI modules.StorageAPI NetworkAPI modules.NetworkAPI CoreAPI modules.CoreAPI RuntimeAPI modules.RuntimeAPI TransactionQueueAPI modules.TransactionQueueAPI RPCAPI modules.RPCAPI SystemAPI modules.SystemAPI Host string RPCPort uint32 WSEnabled bool WSPort uint32 Modules []string WSSubscriptions map[uint32]*WebSocketSubscription BlockAddedReceiver chan *types.Block BlockAddedReceiverDone chan struct{} }
HTTPServerConfig configures the HTTPServer
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service struct to hold rpc service data
func (*Service) BuildMethodNames ¶
BuildMethodNames takes receiver interface and populates rpcMethods array with available
method names
type SubscriptionBaseResponseJSON ¶
type SubscriptionBaseResponseJSON struct { Jsonrpc string `json:"jsonrpc"` Method string `json:"method"` Params interface{} `json:"params"` Subscription uint32 `json:"subscription"` }
SubscriptionBaseResponseJSON for base json response
type SubscriptionResponseJSON ¶
type SubscriptionResponseJSON struct { Jsonrpc string `json:"jsonrpc"` Result uint32 `json:"result"` ID float64 `json:"id"` }
SubscriptionResponseJSON for json subscription responses
type WebSocketSubscription ¶
WebSocketSubscription holds subscription details