Documentation
¶
Index ¶
- Constants
- func NewHTTPServer(conf *ServerConfiguration, obs Observability, registrars ...Registrar) (*http.Server, error)
- func NewRESTServer(addr string, maxBodySize int64, obs Observability, registrars ...Registrar) *http.Serverdeprecated
- type API
- type AdminAPI
- type NodeInfoResponse
- type Observability
- type PeerInfo
- type Registrar
- type RegistrarFunc
- type RequestLimiter
- type RequestTokenCost
- type ServerConfiguration
- type StateAPI
- func (s *StateAPI) GetBlock(ctx context.Context, blockNumber hex.Uint64) (_ hex.Bytes, retErr error)
- func (s *StateAPI) GetRoundInfo(ctx context.Context) (_ *partition.RoundInfo, retErr error)
- func (s *StateAPI) GetTransactionProof(ctx context.Context, txHash hex.Bytes) (_ *TransactionRecordAndProof, retErr error)
- func (s *StateAPI) GetTrustBase(epochNumber hex.Uint64) (_ types.RootTrustBase, retErr error)
- func (s *StateAPI) GetUnit(unitID types.UnitID, includeStateProof bool) (_ *Unit[any], retErr error)
- func (s *StateAPI) GetUnits(unitTypeID *uint32, sinceUnitID *types.UnitID, limit *int) (_ []types.UnitID, retErr error)
- func (s *StateAPI) GetUnitsByOwnerID(ownerID hex.Bytes, sinceUnitID *types.UnitID, limit *int) (_ []types.UnitID, retErr error)
- func (s *StateAPI) SendTransaction(ctx context.Context, txBytes hex.Bytes) (_ hex.Bytes, retErr error)
- type StateAPIOption
- func WithGetUnits(withGetUnits bool) StateAPIOption
- func WithOwnerIndex(ownerIndex partition.IndexReader) StateAPIOption
- func WithRateLimit(rateLimit int) StateAPIOption
- func WithResponseItemLimit(limit int) StateAPIOption
- func WithShardConf(shardConf *types.PartitionDescriptionRecord) StateAPIOption
- type StateAPIOptions
- type TransactionRecordAndProof
- type Unit
Constants ¶
const ( DefaultMaxBodyBytes int64 = 4194304 // 4MB DefaultBatchItemLimit int = 1000 DefaultBatchResponseSizeLimit int = int(DefaultMaxBodyBytes) )
Variables ¶
This section is empty.
Functions ¶
func NewHTTPServer ¶
func NewHTTPServer(conf *ServerConfiguration, obs Observability, registrars ...Registrar) (*http.Server, error)
func NewRESTServer
deprecated
Types ¶
type AdminAPI ¶
type AdminAPI struct {
// contains filtered or unexported fields
}
func NewAdminAPI ¶
func NewAdminAPI(node partitionNode, self *network.Peer, obs Observability) *AdminAPI
func (*AdminAPI) GetNodeInfo ¶
func (s *AdminAPI) GetNodeInfo(ctx context.Context) (_ *NodeInfoResponse, retErr error)
GetNodeInfo returns information about the node.
type NodeInfoResponse ¶
type NodeInfoResponse struct {
NetworkID types.NetworkID `json:"networkId"` // hex encoded network identifier
PartitionID types.PartitionID `json:"partitionId"` // hex encoded partition identifier
PartitionTypeID types.PartitionTypeID `json:"partitionTypeId"` // hex encoded partition identifier
PermissionedMode bool `json:"permissionedMode"`
FeelessMode bool `json:"feelessMode"`
Self PeerInfo `json:"self"` // information about this peer
BootstrapNodes []PeerInfo `json:"bootstrapNodes"`
RootValidators []PeerInfo `json:"rootValidators"`
PartitionValidators []PeerInfo `json:"partitionValidators"`
OpenConnections []PeerInfo `json:"openConnections"` // all libp2p connections to other peers in the network
}
type Observability ¶
type Observability interface {
Meter(name string, opts ...metric.MeterOption) metric.Meter
PrometheusRegisterer() prometheus.Registerer
Logger() *slog.Logger
}
type PeerInfo ¶
type PeerInfo struct {
NodeID string `json:"nodeId"`
Addresses []multiaddr.Multiaddr `json:"addresses"`
}
func (*PeerInfo) UnmarshalJSON ¶
type RegistrarFunc ¶
RegistrarFunc type is an adapter to allow the use of ordinary function as Registrar.
func MetricsEndpoints ¶
func MetricsEndpoints(pr prometheus.Registerer) RegistrarFunc
func NodeEndpoints ¶
func NodeEndpoints(node partitionNode, obs Observability) RegistrarFunc
func (RegistrarFunc) Register ¶
func (f RegistrarFunc) Register(r *mux.Router)
type RequestLimiter ¶
type RequestLimiter struct {
// contains filtered or unexported fields
}
func NewRequestLimiter ¶
func NewRequestLimiter(rateLimit int, tokenCosts []RequestTokenCost, log *slog.Logger) *RequestLimiter
NewRequestLimiter returns a new RequestLimiter. Requests are limited based of input cost. Overall limit is "highest cost * rateLimit".
func (*RequestLimiter) CheckRequestAllowed ¶
func (l *RequestLimiter) CheckRequestAllowed(request string) error
type RequestTokenCost ¶
type RequestTokenCost struct {
// contains filtered or unexported fields
}
type ServerConfiguration ¶
type ServerConfiguration struct {
// Address specifies the TCP address for the server to listen on, in the form "host:port".
// REST server isn't initialised if Address is empty.
Address string
// ReadTimeout is the maximum duration for reading the entire request, including the body. A zero or negative
// value means there will be no timeout.
ReadTimeout time.Duration
// ReadHeaderTimeout is the amount of time allowed to read request headers. If ReadHeaderTimeout is zero, the
// value of ReadTimeout is used. If both are zero, there is no timeout.
ReadHeaderTimeout time.Duration
// WriteTimeout is the maximum duration before timing out writes of the response. A zero or negative value means
// there will be no timeout.
WriteTimeout time.Duration
// IdleTimeout is the maximum amount of time to wait for the next request when keep-alive is enabled. If
// IdleTimeout is zero, the value of ReadTimeout is used. If both are zero, there is no timeout.
IdleTimeout time.Duration
// MaxHeaderBytes controls the maximum number of bytes the server will read parsing the request header's keys
// and values, including the request line. It does not limit the size of the request body. If zero,
// http.DefaultMaxHeaderBytes is used.
MaxHeaderBytes int
// MaxHeaderBytes controls the maximum number of bytes the server will read parsing the request body. If zero,
// MaxBodyBytes is used.
MaxBodyBytes int64
// BatchItemLimit is the maximum number of requests in a batch.
BatchItemLimit int
// BatchResponseSizeLimit is the maximum number of response bytes across all requests in a batch.
BatchResponseSizeLimit int
Router Registrar
// APIs contains is an array of enabled RPC services.
APIs []API
}
ServerConfiguration is a common configuration for RPC servers.
func (*ServerConfiguration) IsAddressEmpty ¶
func (c *ServerConfiguration) IsAddressEmpty() bool
type StateAPI ¶
type StateAPI struct {
// contains filtered or unexported fields
}
func NewStateAPI ¶
func NewStateAPI(node partitionNode, obs Observability, opts ...StateAPIOption) *StateAPI
func (*StateAPI) GetBlock ¶
func (s *StateAPI) GetBlock(ctx context.Context, blockNumber hex.Uint64) (_ hex.Bytes, retErr error)
GetBlock returns block for the given block number.
func (*StateAPI) GetRoundInfo ¶
GetRoundInfo returns the current round number and epoch as seen by the node.
func (*StateAPI) GetTransactionProof ¶
func (s *StateAPI) GetTransactionProof(ctx context.Context, txHash hex.Bytes) (_ *TransactionRecordAndProof, retErr error)
GetTransactionProof returns transaction record and proof for the given transaction hash.
func (*StateAPI) GetTrustBase ¶
GetTrustBase returns trust base for the given epoch.
func (*StateAPI) GetUnit ¶
func (s *StateAPI) GetUnit(unitID types.UnitID, includeStateProof bool) (_ *Unit[any], retErr error)
GetUnit returns unit data and optionally the state proof for the given unitID.
func (*StateAPI) GetUnits ¶
func (s *StateAPI) GetUnits(unitTypeID *uint32, sinceUnitID *types.UnitID, limit *int) (_ []types.UnitID, retErr error)
GetUnits returns list of unit identifiers, optionally filtered by the given unit type identifier.
type StateAPIOption ¶
type StateAPIOption func(*StateAPIOptions)
func WithGetUnits ¶
func WithGetUnits(withGetUnits bool) StateAPIOption
func WithOwnerIndex ¶
func WithOwnerIndex(ownerIndex partition.IndexReader) StateAPIOption
func WithRateLimit ¶
func WithRateLimit(rateLimit int) StateAPIOption
func WithResponseItemLimit ¶
func WithResponseItemLimit(limit int) StateAPIOption
func WithShardConf ¶
func WithShardConf(shardConf *types.PartitionDescriptionRecord) StateAPIOption
type StateAPIOptions ¶
type StateAPIOptions struct {
// contains filtered or unexported fields
}