Documentation
¶
Index ¶
- func LocalRequestOnly(r *rpc.RequestInfo, i interface{}) error
- func LocalhostFilter() *ipfilter.IPFilter
- func NewWSConn(conn *websocket.Conn, cfg *HTTPServerConfig) *subscription.WSConn
- type API
- type BlockAPI
- type BlockFinalityAPI
- type BlockProducerAPI
- type CoreAPI
- type DotUpCodec
- type DotUpCodecRequest
- type HTTPServer
- type HTTPServerConfig
- type NetworkAPI
- type Service
- type StorageAPI
- type SyncAPI
- type SyncStateAPI
- type SystemAPI
- type Telemetry
- type TransactionStateAPI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LocalRequestOnly ¶ added in v0.3.0
func LocalRequestOnly(r *rpc.RequestInfo, i interface{}) error
LocalRequestOnly HTTP handler to restrict to only local connections
func LocalhostFilter ¶ added in v0.3.0
LocalhostFilter creates a ipfilter object for localhost
func NewWSConn ¶ added in v0.2.0
func NewWSConn(conn *websocket.Conn, cfg *HTTPServerConfig) *subscription.WSConn
NewWSConn to create new WebSocket Connection struct
Types ¶
type BlockAPI ¶ added in v0.8.0
type BlockAPI interface { GetHeader(hash common.Hash) (*types.Header, error) BestBlockHash() common.Hash GetBlockByHash(hash common.Hash) (*types.Block, error) GetHashByNumber(blockNumber uint) (common.Hash, error) GetFinalisedHash(uint64, uint64) (common.Hash, error) GetHighestFinalisedHash() (common.Hash, error) HasJustification(hash common.Hash) (bool, error) GetJustification(hash common.Hash) ([]byte, error) GetImportedBlockNotifierChannel() chan *types.Block FreeImportedBlockNotifierChannel(ch chan *types.Block) GetFinalisedNotifierChannel() chan *types.FinalisationInfo FreeFinalisedNotifierChannel(ch chan *types.FinalisationInfo) RangeInMemory(start, end common.Hash) ([]common.Hash, error) RegisterRuntimeUpdatedChannel(ch chan<- runtime.Version) (uint32, error) UnregisterRuntimeUpdatedChannel(id uint32) bool GetRuntime(blockHash common.Hash) (runtime runtime.Instance, err error) }
BlockAPI is the interface for the block state
type BlockFinalityAPI ¶ added in v0.8.0
type BlockFinalityAPI interface { GetSetID() uint64 GetRound() uint64 GetVoters() grandpa.Voters PreVotes() []ed25519.PublicKeyBytes PreCommits() []ed25519.PublicKeyBytes }
BlockFinalityAPI is the interface for handling block finalisation methods
type BlockProducerAPI ¶ added in v0.8.0
type BlockProducerAPI interface { Pause() error Resume() error EpochLength() uint64 SlotDuration() uint64 }
BlockProducerAPI is the interface for BlockProducer methods
type CoreAPI ¶ added in v0.8.0
type CoreAPI interface { InsertKey(kp core.KeyPair, keystoreType string) error HasKey(pubKeyStr string, keyType string) (bool, error) GetRuntimeVersion(bhash *common.Hash) (runtime.Version, error) HandleSubmittedExtrinsic(types.Extrinsic) error GetMetadata(bhash *common.Hash) ([]byte, error) DecodeSessionKeys(enc []byte) ([]byte, error) GetReadProofAt(block common.Hash, keys [][]byte) (common.Hash, [][]byte, error) }
CoreAPI is the interface for the core methods
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 behaviour 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 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 { LogLvl log.Level BlockAPI BlockAPI StorageAPI StorageAPI NetworkAPI NetworkAPI CoreAPI CoreAPI BlockProducerAPI BlockProducerAPI BlockFinalityAPI BlockFinalityAPI TransactionQueueAPI TransactionStateAPI RPCAPI API SystemAPI SystemAPI SyncStateAPI SyncStateAPI SyncAPI SyncAPI NodeStorage *runtime.NodeStorage RPCUnsafe bool RPCExternal bool RPCUnsafeExternal bool Host string RPCPort uint32 WSExternal bool WSUnsafeExternal bool WSPort uint32 Modules []string }
HTTPServerConfig configures the HTTPServer
type NetworkAPI ¶ added in v0.8.0
type NetworkAPI interface { Health() common.Health NetworkState() common.NetworkState Peers() []common.PeerInfo NodeRoles() common.NetworkRole Stop() error Start() error StartingBlock() int64 AddReservedPeers(addrs ...string) error RemoveReservedPeers(addrs ...string) error }
NetworkAPI interface for network state methods
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 StorageAPI ¶ added in v0.8.0
type StorageAPI interface { GetStorage(root *common.Hash, key []byte) ([]byte, error) GetStorageChild(root *common.Hash, keyToChild []byte) (*trie.Trie, error) GetStorageFromChild(root *common.Hash, keyToChild, key []byte) ([]byte, error) GetStorageByBlockHash(bhash *common.Hash, key []byte) ([]byte, error) Entries(root *common.Hash) (map[string][]byte, error) GetStateRootFromBlock(bhash *common.Hash) (*common.Hash, error) GetKeysWithPrefix(root *common.Hash, prefix []byte) ([][]byte, error) RegisterStorageObserver(observer state.Observer) UnregisterStorageObserver(observer state.Observer) }
StorageAPI is the interface for the storage state
type SyncAPI ¶ added in v0.8.0
type SyncAPI interface {
HighestBlock() uint
}
SyncAPI is the interface to interact with the sync service
type SyncStateAPI ¶ added in v0.8.0
SyncStateAPI is the interface to interact with sync state.
type SystemAPI ¶ added in v0.8.0
type SystemAPI interface { SystemName() string SystemVersion() string Properties() map[string]interface{} ChainType() string ChainName() string }
SystemAPI is the interface for handling system methods
type TransactionStateAPI ¶ added in v0.8.0
type TransactionStateAPI interface { AddToPool(*transaction.ValidTransaction) common.Hash Pending() []*transaction.ValidTransaction GetStatusNotifierChannel(ext types.Extrinsic) chan transaction.Status FreeStatusNotifierChannel(ch chan transaction.Status) }
TransactionStateAPI ...