Documentation ¶
Index ¶
- Constants
- func GetMethods(codec Codec, service *Service) map[string]RequestHandlerFunc
- func GetRangeFilter(op, fName string) (func(a, b uint64) bool, error)
- func GetStringFilter(op, fName string) (func(s0, s1 string) bool, error)
- func NewCORSMiddleware(options rpcConf.CORS) gin.HandlerFunc
- func ParseNumberValue(value string) (uint64, error)
- type AccountBalanceFilter
- type AccountCodeFilter
- type AccountOutput
- type AccountsOutput
- type AddressInput
- type Block
- type BlockInfoInput
- type BlockInput
- type BlockMeta
- type BlockOutput
- type BlockTxsOutput
- type BlocksInput
- type BlocksOutput
- type BroadcastTxOutput
- type ChainIdOutput
- type Codec
- type CompositeFilter
- type ConfigurableFilter
- type DumpConsensusStateOutput
- type DumpstorageOutput
- type Filter
- type FilterData
- type FilterFactory
- type FilterListInput
- type GenesisOutput
- type HttpService
- type JSONService
- type JsonRpcServer
- type LastBlockInfoOutput
- type MatchAllFilter
- type NetInfoOutput
- func (info *NetInfoOutput) Decode(bs []byte) error
- func (info *NetInfoOutput) Encode() ([]byte, error)
- func (info *NetInfoOutput) Marshal() ([]byte, error)
- func (info *NetInfoOutput) MarshalTo(data []byte) (int, error)
- func (info NetInfoOutput) Size() int
- func (info *NetInfoOutput) Unmarshal(bs []byte) error
- type Peer
- type PeersInput
- type PeersOutput
- type RPCError
- type RPCErrorResponse
- type RPCRequest
- type RPCResponse
- type RPCResultResponse
- type RequestHandlerFunc
- type ServeProcess
- type Server
- type Service
- func (s *Service) BlockchainInfo() *blockchain.Blockchain
- func (s *Service) ChainIdentifiers() (*ChainIdOutput, error)
- func (s *Service) DumpConsensusState() (*DumpConsensusStateOutput, error)
- func (s *Service) DumpStorage(address crypto.Address) (*DumpstorageOutput, error)
- func (s *Service) Genesis() *GenesisOutput
- func (s *Service) GetAccount(address crypto.Address) (*AccountOutput, error)
- func (s *Service) GetBlock(height uint64) (*BlockOutput, error)
- func (s *Service) GetStorage(address crypto.Address, key []byte) (*StorageOutput, error)
- func (s *Service) GetValidator(address crypto.Address) (*ValidatorOutput, error)
- func (s *Service) LastBlockInfo(blockWithin string) (*LastBlockInfoOutput, error)
- func (s *Service) ListAccounts(predicate func(*account.Account) bool) (*AccountsOutput, error)
- func (s *Service) ListBlockTxs(height uint64) (*BlockTxsOutput, error)
- func (s *Service) ListBlocks(minHeight, maxHeight uint64) (*BlocksOutput, error)
- func (s *Service) ListUnconfirmedTxs(maxTxs int) (*UnconfirmedTxsOutput, error)
- func (s *Service) ListValidators() (*ValidatorsOutput, error)
- func (s *Service) NetInfo() (*NetInfoOutput, error)
- func (s *Service) Peers() (*PeersOutput, error)
- func (s *Service) State() *state.State
- func (s *Service) Status() (*StatusOutput, error)
- func (s *Service) Transactor() *execution.Transactor
- type StatusOutput
- type StorageAtInput
- type StorageItem
- type StorageOutput
- type TCodec
- type UnconfirmedTxsOutput
- type ValidatorOutput
- type ValidatorsOutput
Constants ¶
const ( RPCErrorServerError = -32000 RPCErrorInvalidRequest = -32600 RPCErrorMethodNotFound = -32601 RPCErrorInvalidParams = -32602 RPCErrorInternalError = -32603 RPCErrorParseError = -32700 )
JSON-RPC 2.0 error codes.
const ( GALLACTIC = "gallactic." GET_ACCOUNTS = GALLACTIC + "getAccounts" GET_ACCOUNT = GALLACTIC + "getAccount" GET_VALIDATOR = GALLACTIC + "getValidator" GET_STORAGE = GALLACTIC + "getStorage" GET_STORAGE_AT = GALLACTIC + "getStorageAt" GET_STATUS = GALLACTIC + "getStatus" GET_LATEST_BLOCK = GALLACTIC + "getLatestBlock" GET_BLOCKS = GALLACTIC + "getBlocks" GET_BLOCK = GALLACTIC + "getBlock" GET_CONSENSUS_STATE = GALLACTIC + "getConsensusState" GET_VALIDATORS = GALLACTIC + "getValidators" GET_NETWORK_INFO = GALLACTIC + "getNetworkInfo" GET_CHAIN_ID = GALLACTIC + "getChainId" GET_PEERS = GALLACTIC + "getPeers" GET_GENESIS = GALLACTIC + "getGenesis" BROADCAST_TX = GALLACTIC + "broadcastTx" GET_UNCONFIRMED_TXS = GALLACTIC + "getUnconfirmedTxs" GET_BLOCK_TXS = GALLACTIC + "getBlockTxs" GET_LastBlock_Info = GALLACTIC + "getLastBlockInfo" )
const MaxBlockLookback = 1000
Magic! Should probably be configurable, but not shouldn't be so huge we end up DoSing ourselves.
Variables ¶
This section is empty.
Functions ¶
func GetMethods ¶
func GetMethods(codec Codec, service *Service) map[string]RequestHandlerFunc
func NewCORSMiddleware ¶
func NewCORSMiddleware(options rpcConf.CORS) gin.HandlerFunc
func ParseNumberValue ¶
Types ¶
type AccountBalanceFilter ¶
type AccountBalanceFilter struct {
// contains filtered or unexported fields
}
Filter for account balance. Ops: All
func (*AccountBalanceFilter) Configure ¶
func (abf *AccountBalanceFilter) Configure(fd *FilterData) error
func (*AccountBalanceFilter) Match ¶
func (abf *AccountBalanceFilter) Match(v interface{}) bool
type AccountCodeFilter ¶
type AccountCodeFilter struct {
// contains filtered or unexported fields
}
Filter for account code. Ops: == or != Could be used to match against nil, to see if an account is a contract account.
func (*AccountCodeFilter) Configure ¶
func (acf *AccountCodeFilter) Configure(fd *FilterData) error
func (*AccountCodeFilter) Match ¶
func (acf *AccountCodeFilter) Match(v interface{}) bool
type AccountOutput ¶
type AccountsOutput ¶
type AddressInput ¶
type Block ¶
Needed for amino handling of interface types
func (Block) MarshalJSON ¶
func (*Block) UnmarshalJSON ¶
type BlockInfoInput ¶ added in v0.5.0
type BlockInfoInput struct {
BlockWithin string `json:"blockWithin"`
}
type BlockInput ¶
type BlockInput struct {
Height uint64 `json:"height"`
}
type BlockOutput ¶
type BlockTxsOutput ¶
type BlocksInput ¶
type BlocksOutput ¶
type BroadcastTxOutput ¶
func (BroadcastTxOutput) MarshalJSON ¶
func (rbt BroadcastTxOutput) MarshalJSON() ([]byte, error)
func (BroadcastTxOutput) UnmarshalJSON ¶
func (rbt BroadcastTxOutput) UnmarshalJSON(data []byte) (err error)
type ChainIdOutput ¶
type Codec ¶
type CompositeFilter ¶
type CompositeFilter struct {
// contains filtered or unexported fields
}
Filter made up of many filters.
func (*CompositeFilter) Match ¶
func (cf *CompositeFilter) Match(v interface{}) bool
func (*CompositeFilter) SetData ¶
func (cf *CompositeFilter) SetData(filters []Filter)
type ConfigurableFilter ¶
type ConfigurableFilter interface { Filter Configure(*FilterData) error }
A filter that can be configured with in-data.
type DumpConsensusStateOutput ¶
type DumpConsensusStateOutput struct { RoundState consensusTypes.RoundStateSimple PeerRoundStates []*consensusTypes.PeerRoundState }
type DumpstorageOutput ¶
type DumpstorageOutput struct {
StorageItems []StorageItem
}
type FilterData ¶
type FilterData struct { Field string `json:"field"` Op string `json:"op"` Value string `json:"value"` }
Used to filter. Op can be any of the following: The usual relative operators: <, >, <=, >=, ==, != (where applicable) A range parameter (see: https://help.github.com/articles/search-syntax/)
type FilterFactory ¶
type FilterFactory struct {
// contains filtered or unexported fields
}
Used to generate filters based on filter data. Keeping separate pools for "edge cases" (Composite and MatchAll)
func NewAccountFilterFactory ¶
func NewAccountFilterFactory() *FilterFactory
func NewFilterFactory ¶
func NewFilterFactory() *FilterFactory
func (*FilterFactory) NewFilter ¶
func (ff *FilterFactory) NewFilter(fdArr []*FilterData) (Filter, error)
Creates a new filter given the input data array. If the array is zero length or nil, an empty filter will be returned that returns true on all matches. If the array is of size 1, a regular filter is returned, otherwise a CompositeFieldFilter is returned, which is a special filter that contains a number of other filters. It implements AccountFieldFilter, and will match an account only if all the sub-filters matches.
func (*FilterFactory) RegisterFilterPool ¶
func (ff *FilterFactory) RegisterFilterPool(fieldName string, pool *sync.Pool)
type FilterListInput ¶
type FilterListInput struct {
Filters []*FilterData `json:"filters"`
}
type GenesisOutput ¶
type HttpService ¶
type HttpService interface {
Process(*http.Request, http.ResponseWriter)
}
func NewJSONService ¶
func NewJSONService(codec Codec, service *Service) HttpService
Create a new JSON-RPC 2.0 service for gallactic
type JSONService ¶
type JSONService struct {
// contains filtered or unexported fields
}
func (*JSONService) Process ¶
func (js *JSONService) Process(r *http.Request, w http.ResponseWriter)
Process a request.
type JsonRpcServer ¶
type JsonRpcServer struct {
// contains filtered or unexported fields
}
Server used to handle JSON-RPC 2.0 requests. Implements server.Server
func NewJSONServer ¶
func NewJSONServer(service HttpService) *JsonRpcServer
Create a new JsonRpcServer
func (*JsonRpcServer) Running ¶
func (jrs *JsonRpcServer) Running() bool
Is the server currently running?
func (*JsonRpcServer) Shutdown ¶
func (jrs *JsonRpcServer) Shutdown(ctx context.Context) error
Shut the server down. Does nothing.
func (*JsonRpcServer) Start ¶
func (jrs *JsonRpcServer) Start(config *rpcConfig.ServerConfig, router *gin.Engine)
Start adds the rpc path to the router.
type LastBlockInfoOutput ¶
type MatchAllFilter ¶
type MatchAllFilter struct{}
Rubberstamps everything.
func (*MatchAllFilter) Match ¶
func (maf *MatchAllFilter) Match(v interface{}) bool
type NetInfoOutput ¶
func (*NetInfoOutput) Decode ¶ added in v0.4.0
func (info *NetInfoOutput) Decode(bs []byte) error
func (*NetInfoOutput) Encode ¶ added in v0.4.0
func (info *NetInfoOutput) Encode() ([]byte, error)
protobuf marshal,unmarshal and size methods
func (*NetInfoOutput) Marshal ¶ added in v0.4.0
func (info *NetInfoOutput) Marshal() ([]byte, error)
func (*NetInfoOutput) MarshalTo ¶ added in v0.4.0
func (info *NetInfoOutput) MarshalTo(data []byte) (int, error)
func (NetInfoOutput) Size ¶ added in v0.4.0
func (info NetInfoOutput) Size() int
func (*NetInfoOutput) Unmarshal ¶ added in v0.4.0
func (info *NetInfoOutput) Unmarshal(bs []byte) error
type PeersInput ¶
type PeersOutput ¶
type PeersOutput struct {
Peers []*Peer
}
type RPCErrorResponse ¶
type RPCErrorResponse struct { Error *RPCError `json:"error"` Id string `json:"id"` JSONRPC string `json:"jsonrpc"` }
RPCErrorResponse MUST NOT contain the result member if an error occurred
func (*RPCErrorResponse) AssertIsRPCResponse ¶
func (rpcErrorResponse *RPCErrorResponse) AssertIsRPCResponse() bool
AssertIsRPCResponse implements a marker method for RPCErrorResponse to implement the interface RPCResponse
type RPCRequest ¶
type RPCRequest struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params json.RawMessage `json:"params"` Id string `json:"id"` }
Request and Response objects. Id is a string. Error data not used. Refer to JSON-RPC specification http://www.jsonrpc.org/specification
func NewRPCRequest ¶
func NewRPCRequest(id string, method string, params json.RawMessage) *RPCRequest
Create a new RPC request. This is the generic struct that is passed to RPC methods
type RPCResponse ¶
type RPCResponse interface {
AssertIsRPCResponse() bool
}
RPCResponse MUST follow the JSON-RPC specification for Response object reference: http://www.jsonrpc.org/specification#response_object
func NewRPCErrorResponse ¶
func NewRPCErrorResponse(id string, code int, message string) RPCResponse
NewRPCErrorResponse creates a new error-response object from the error code and message
func NewRPCResponse ¶
func NewRPCResponse(id string, res interface{}) RPCResponse
NewRPCResponse creates a new response object from a result
type RPCResultResponse ¶
type RPCResultResponse struct { Result interface{} `json:"result"` Id string `json:"id"` JSONRPC string `json:"jsonrpc"` }
RPCResultResponse MUST NOT contain the error member if no error occurred
func (*RPCResultResponse) AssertIsRPCResponse ¶
func (rpcResultResponse *RPCResultResponse) AssertIsRPCResponse() bool
AssertIsRPCResponse implements a marker method for RPCResultResponse to implement the interface RPCResponse
type RequestHandlerFunc ¶
type RequestHandlerFunc func(request *RPCRequest, requester interface{}) (interface{}, int, error)
Used to handle requests. interface{} param is a wildcard used for example with socket events.
type ServeProcess ¶
type ServeProcess struct {
// contains filtered or unexported fields
}
The ServeProcess wraps all the Servers. Starting it will add all the server handlers to the router and start listening for incoming requests. There is also startup and shutdown events that can be listened to, on top of any events that the servers may have (the default websocket server has events for monitoring sessions. Startup event listeners should be added before calling 'Start()'. Stop event listeners can be added up to the point where the server is stopped and the event is fired.
func NewServeProcess ¶
func NewServeProcess(config *rpcConf.ServerConfig, servers ...Server) (*ServeProcess, error)
Creates a new serve process.
func (*ServeProcess) Shutdown ¶
func (serveProcess *ServeProcess) Shutdown(ctx context.Context) error
Stop will release the port, process any remaining requests up until the timeout duration is passed, at which point it will abort them and shut down.
func (*ServeProcess) Start ¶
func (serveProcess *ServeProcess) Start() error
Initializes all the servers and starts listening for connections.
func (*ServeProcess) StartEventChannel ¶
func (serveProcess *ServeProcess) StartEventChannel() <-chan struct{}
Get a start-event channel from the server. The start event is fired after the Start() function is called, and after the server has started listening for incoming connections. An error here .
func (*ServeProcess) StopEventChannel ¶
func (serveProcess *ServeProcess) StopEventChannel() <-chan struct{}
Get a stop-event channel from the server. The event happens after the Stop() function has been called, and after the timeout has passed. When the timeout has passed it will wait for confirmation from the http.Server, which normally takes a very short time (milliseconds).
type Server ¶
type Server interface { Start(*rpcConf.ServerConfig, *gin.Engine) Running() bool Shutdown(ctx context.Context) error }
A server serves a number of different http calls.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Base service that provides implementation for all underlying RPC methods
func NewService ¶
func NewService(ctx context.Context, blockchain *blockchain.Blockchain, transactor *execution.Transactor, nView *query.NodeView) *Service
func (*Service) BlockchainInfo ¶
func (s *Service) BlockchainInfo() *blockchain.Blockchain
func (*Service) ChainIdentifiers ¶
func (s *Service) ChainIdentifiers() (*ChainIdOutput, error)
func (*Service) DumpConsensusState ¶
func (s *Service) DumpConsensusState() (*DumpConsensusStateOutput, error)
func (*Service) DumpStorage ¶
func (s *Service) DumpStorage(address crypto.Address) (*DumpstorageOutput, error)
func (*Service) Genesis ¶
func (s *Service) Genesis() *GenesisOutput
func (*Service) GetAccount ¶
func (s *Service) GetAccount(address crypto.Address) (*AccountOutput, error)
func (*Service) GetStorage ¶
func (*Service) GetValidator ¶ added in v0.3.0
func (s *Service) GetValidator(address crypto.Address) (*ValidatorOutput, error)
func (*Service) LastBlockInfo ¶
func (s *Service) LastBlockInfo(blockWithin string) (*LastBlockInfoOutput, error)
func (*Service) ListAccounts ¶
func (*Service) ListBlockTxs ¶
func (s *Service) ListBlockTxs(height uint64) (*BlockTxsOutput, error)
func (*Service) ListBlocks ¶
func (s *Service) ListBlocks(minHeight, maxHeight uint64) (*BlocksOutput, error)
Returns the current blockchain height and metadata for a range of blocks between minHeight and maxHeight. Only returns maxBlockLookback block metadata from the top of the range of blocks. Passing 0 for maxHeight sets the upper height of the range to the current blockchain height.
func (*Service) ListUnconfirmedTxs ¶
func (s *Service) ListUnconfirmedTxs(maxTxs int) (*UnconfirmedTxsOutput, error)
func (*Service) ListValidators ¶
func (s *Service) ListValidators() (*ValidatorsOutput, error)
func (*Service) NetInfo ¶
func (s *Service) NetInfo() (*NetInfoOutput, error)
func (*Service) Peers ¶
func (s *Service) Peers() (*PeersOutput, error)
func (*Service) Status ¶
func (s *Service) Status() (*StatusOutput, error)
func (*Service) Transactor ¶
func (s *Service) Transactor() *execution.Transactor
type StatusOutput ¶
type StorageAtInput ¶
type TCodec ¶
type TCodec struct { }
Codec that uses tendermints 'binary' package for JSON.
func (*TCodec) DecodeBytes ¶
Decode from a byte array.
func (*TCodec) EncodeBytes ¶
Encode to a byte array.