Documentation ¶
Index ¶
- Constants
- Variables
- func AddSubscription(subManager *SubcriptionManager, subRequest *SubcriptionRequest, ...) error
- func AuthFail(w http.ResponseWriter)
- func GenCertPair(certFile, keyFile string) error
- func IsValidIDType(id interface{}) bool
- func NewCorsHeader(w http.ResponseWriter)
- func NewTLSCertPair(organization string, validUntil time.Time, extraHosts []string) (cert, key []byte, err error)
- func RemoveSubcription(subManager *SubcriptionManager, subRequest *SubcriptionRequest) error
- type ConsensusEngine
- type ConvertedPrice
- type CountResult
- type DeBridgeLogger
- type HttpServer
- func (httpServer *HttpServer) DecrementClients()
- func (httpServer *HttpServer) GetBeaconChainDatabase() incdb.Database
- func (httpServer *HttpServer) GetBlockchain() *blockchain.BlockChain
- func (httpServer *HttpServer) GetShardChainDatabase(shardID byte) incdb.Database
- func (httpServer *HttpServer) IncrementClients()
- func (httpServer *HttpServer) Init(config *RpcServerConfig)
- func (httpServer *HttpServer) ProcessRpcRequest(w http.ResponseWriter, r *http.Request, isLimitedUser bool)
- func (httpServer *HttpServer) Start() error
- func (httpServer *HttpServer) Stop()
- type JsonRequest
- type JsonResponse
- type PDEContribution
- type PDEInfoFromBeaconBlock
- type PDETrade
- type PDEWithdrawal
- type Result
- type RpcLogger
- type RpcServer
- type RpcServerConfig
- type RpcSubResult
- type SubcriptionManager
- type SubcriptionRequest
- type SubcriptionResult
- type UsageFlag
- type WsServer
Constants ¶
const (
// reward
CreateRawWithDrawTransaction = "withdrawreward"
)
rpc cmd method
const (
RpcServerVersion = "1.0"
)
Variables ¶
var BLogger = DeBridgeLogger{}
var (
ErrParseTransaction = errors.New("Parse transaction failed")
)
var HttpHandler = map[string]httpHandler{ CreateRawWithDrawTransaction: (*HttpServer).handleCreateAndSendWithDrawTransaction, // contains filtered or unexported fields }
Commands valid for normal user
var LimitedHttpHandler = map[string]httpHandler{ // contains filtered or unexported fields }
Commands that are available to a limited user
var Logger = RpcLogger{}
Global instant to use
var WsHandler = map[string]wsHandler{ // contains filtered or unexported fields }
Functions ¶
func AddSubscription ¶
func AddSubscription(subManager *SubcriptionManager, subRequest *SubcriptionRequest, closeChan chan struct{}) error
func AuthFail ¶
func AuthFail(w http.ResponseWriter)
AuthFail sends a Message back to the client if the http auth is rejected.
func GenCertPair ¶
genCertPair generates a key/cert pair to the paths provided.
func IsValidIDType ¶
func IsValidIDType(id interface{}) bool
IsValidIDType checks that the Id field (which can go in any of the JSON-RPC requests, responses, or notifications) is valid. JSON-RPC 1.0 allows any valid JSON type. JSON-RPC 2.0 (which coind follows for some parts) only allows string, number, or null, so this function restricts the allowed types to that list. This function is only provided in case the caller is manually marshalling for some reason. The functions which accept an Id in this package already call this function to ensure the provided id is valid.
func NewCorsHeader ¶
func NewCorsHeader(w http.ResponseWriter)
func NewTLSCertPair ¶
func NewTLSCertPair(organization string, validUntil time.Time, extraHosts []string) (cert, key []byte, err error)
NewTLSCertPair returns a new PEM-encoded x.509 certificate pair based on a 521-bit ECDSA private key. The machine's local interface addresses and all variants of IPv4 and IPv6 localhost are included as valid IP addresses.
func RemoveSubcription ¶
func RemoveSubcription(subManager *SubcriptionManager, subRequest *SubcriptionRequest) error
Types ¶
type ConsensusEngine ¶
type ConsensusEngine interface {
ExtractBridgeValidationData(block common.BlockInterface) ([][]byte, []int, error)
}
type ConvertedPrice ¶
type DeBridgeLogger ¶
type DeBridgeLogger struct {
// contains filtered or unexported fields
}
func (*DeBridgeLogger) Init ¶
func (self *DeBridgeLogger) Init(inst common.Logger)
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
func (*HttpServer) DecrementClients ¶
func (httpServer *HttpServer) DecrementClients()
DecrementClients subtracts one from the number of connected RPC clients. Note this only applies to standard clients.
This function is safe for concurrent access.
func (*HttpServer) GetBeaconChainDatabase ¶
func (httpServer *HttpServer) GetBeaconChainDatabase() incdb.Database
func (*HttpServer) GetBlockchain ¶
func (httpServer *HttpServer) GetBlockchain() *blockchain.BlockChain
func (*HttpServer) GetShardChainDatabase ¶
func (httpServer *HttpServer) GetShardChainDatabase(shardID byte) incdb.Database
func (*HttpServer) IncrementClients ¶
func (httpServer *HttpServer) IncrementClients()
IncrementClients adds one to the number of connected RPC clients. Note this only applies to standard clients.
This function is safe for concurrent access.
func (*HttpServer) Init ¶
func (httpServer *HttpServer) Init(config *RpcServerConfig)
func (*HttpServer) ProcessRpcRequest ¶
func (httpServer *HttpServer) ProcessRpcRequest(w http.ResponseWriter, r *http.Request, isLimitedUser bool)
func (*HttpServer) Start ¶
func (httpServer *HttpServer) Start() error
Start is used by rpcserver.go to start the rpc listener.
func (*HttpServer) Stop ¶
func (httpServer *HttpServer) Stop()
Stop is used by rpcserver.go to stop the rpc listener.
type JsonRequest ¶
type JsonRequest struct { Jsonrpc string `json:"Jsonrpc"` Method string `json:"Method"` Params interface{} `json:"Params"` Id interface{} `json:"Id"` }
The JSON-RPC 1.0 spec defines that notifications must have their "id" set to null and states that notifications do not have a response.
A JSON-RPC 2.0 notification is a request with "json-rpc":"2.0", and without an "id" member. The specification states that notifications must not be responded to. JSON-RPC 2.0 permits the null value as a valid request id, therefore such requests are not notifications.
coin Core serves requests with "id":null or even an absent "id", and responds to such requests with "id":null in the response.
Rpc does not respond to any request without and "id" or "id":null, regardless the indicated JSON-RPC protocol version unless RPC quirks are enabled. With RPC quirks enabled, such requests will be responded to if the reqeust does not indicate JSON-RPC version.
RPC quirks can be enabled by the user to avoid compatibility issues with software relying on Core's behavior.
type JsonResponse ¶
type JsonResponse struct { Id *interface{} `json:"Id"` Result json.RawMessage `json:"Result"` Error *rpcservice.RPCError `json:"Error"` Params interface{} `json:"Params"` Method string `json:"Method"` Jsonrpc string `json:"Jsonrpc"` }
JsonResponse is the general form of a JSON-RPC response. The type of the Result field varies from one command to the next, so it is implemented as an interface. The Id field has to be a pointer for Go to put a null in it when empty.
type PDEContribution ¶
type PDEInfoFromBeaconBlock ¶
type PDEInfoFromBeaconBlock struct { PDEContributions []*PDEContribution `json:"PDEContributions"` PDETrades []*PDETrade `json:"PDETrades"` PDEWithdrawals []*PDEWithdrawal `json:"PDEWithdrawals"` BeaconTimeStamp int64 `json:"BeaconTimeStamp"` }
type PDEWithdrawal ¶
type RpcServer ¶
type RpcServer struct { HttpServer *HttpServer WsServer *WsServer RpcServer *http.Server // contains filtered or unexported fields }
rpcServer provides a concurrent safe RPC server to a chain server.
func (*RpcServer) Init ¶
func (rpcServer *RpcServer) Init(config *RpcServerConfig)
func (*RpcServer) RequestedProcessShutdown ¶
func (rpcServer *RpcServer) RequestedProcessShutdown() <-chan struct{}
RequestedProcessShutdown returns a channel that is sent to when an authorized RPC client requests the process to shutdown. If the request can not be read immediately, it is dropped.
type RpcServerConfig ¶
type RpcServerConfig struct { HttpListenters []net.Listener WsListenters []net.Listener ProtocolVersion string ChainParams *blockchain.Params BlockChain *blockchain.BlockChain Blockgen *blockchain.BlockGenerator MemCache *memcache.MemoryCache Database map[int]incdb.Database Wallet *wallet.Wallet ConnMgr *connmanager.ConnManager AddrMgr *addrmanager.AddrManager NodeMode string NetSync *netsync.NetSync Syncker *syncker.SynckerManager Server interface { // Push TxNormal Message PushMessageToAll(message wire.Message) error PushMessageToPeer(message wire.Message, id peer2.ID) error GetNodeRole() string // GetUserKeySet() *incognitokey.KeySet EnableMining(enable bool) error IsEnableMining() bool GetChainMiningStatus(chain int) string GetPublicKeyRole(publicKey string, keyType string) (int, int) GetIncognitoPublicKeyRole(publicKey string) (int, bool, int) GetMinerIncognitoPublickey(publicKey string, keyType string) []byte } ConsensusEngine interface { GetUserLayer() (string, int) GetUserRole() (string, string, int) GetCurrentMiningPublicKey() (publickey string, keyType string) GetAllMiningPublicKeys() []string ExtractBridgeValidationData(block common.BlockInterface) ([][]byte, []int, error) } TxMemPool *mempool.TxPool RPCMaxClients int RPCMaxWSClients int RPCLimitRequestPerDay int RPCLimitRequestErrorPerHour int RPCQuirks bool // Authentication RPCUser string RPCPass string RPCLimitUser string RPCLimitPass string DisableAuth bool // The fee estimator keeps track of how long transactions are left in // the mempool before they are mined into blocks. FeeEstimator map[byte]*mempool.FeeEstimator // IsMiningNode bool // flag mining node. True: mining, False: not mining MiningKeys string // encode of mining key PubSubManager *pubsub.PubSubManager }
type RpcSubResult ¶
type RpcSubResult struct { Result interface{} Error *rpcservice.RPCError }
type SubcriptionManager ¶
type SubcriptionManager struct {
// contains filtered or unexported fields
}
Manage All Subcription from one socket connection
func NewSubscriptionManager ¶
func NewSubscriptionManager(ws *websocket.Conn) *SubcriptionManager
type SubcriptionRequest ¶
type SubcriptionRequest struct { JsonRequest JsonRequest `json:"Request"` Subcription string `json:"Subcription"` Type int `json:"Type"` }
type for subcribe and unsubcribe 0: subcribe 1: unsubcribe
type SubcriptionResult ¶
type SubcriptionResult struct { Subscription string `json:"Subscription"` Result json.RawMessage `json:"Result"` }
type UsageFlag ¶
type UsageFlag uint32
UsageFlag define flags that specify additional properties about the circumstances under which a command can be used.
type WsServer ¶
type WsServer struct {
// contains filtered or unexported fields
}
func (*WsServer) DecrementWsClients ¶
func (wsServer *WsServer) DecrementWsClients()
func (*WsServer) IncrementWsClients ¶
func (wsServer *WsServer) IncrementWsClients()
func (*WsServer) Init ¶
func (wsServer *WsServer) Init(config *RpcServerConfig)
func (*WsServer) ProcessRpcWsRequest ¶
Source Files ¶
- constants.go
- http.go
- http_backuppreload.go
- http_beststate.go
- http_block.go
- http_bridge.go
- http_burn.go
- http_estimatefee.go
- http_general.go
- http_mining.go
- http_outputcoins.go
- http_pde.go
- http_poolinfo.go
- http_portal.go
- http_portalexchangerates.go
- http_portalliquidatetpexchangerates.go
- http_portalportingrequest.go
- http_profilling.go
- http_relaying.go
- http_slash.go
- http_swapbeacon.go
- http_swapbridge.go
- http_testing.go
- http_tx.go
- http_txpool.go
- http_utils.go
- http_wallet.go
- http_withdrawreward.go
- log.go
- request.go
- response.go
- rpcinterface.go
- rpcserver.go
- utils.go
- websocket.go
- ws_account.go
- ws_beststate.go
- ws_block.go
- ws_pool.go
- ws_stake.go
- ws_testws.go
- ws_transaction.go