Documentation
¶
Index ¶
- Variables
- type Node
- type Service
- func (svc *Service) Block(_ context.Context, req *chainjson.BlockRequest) (*chainjson.BlockResponse, *jsonrpc.Error)
- func (svc *Service) BlockResult(_ context.Context, req *chainjson.BlockResultRequest) (*chainjson.BlockResultResponse, *jsonrpc.Error)
- func (svc *Service) ConsensusParams(_ context.Context, _ *chainjson.ConsensusParamsRequest) (*chainjson.ConsensusParamsResponse, *jsonrpc.Error)
- func (svc *Service) Genesis(ctx context.Context, _ *chainjson.GenesisRequest) (*chainjson.GenesisResponse, *jsonrpc.Error)
- func (svc *Service) Health(ctx context.Context) (detail json.RawMessage, happy bool)
- func (svc *Service) HealthMethod(_ context.Context, _ *chainjson.HealthRequest) (*chainjson.HealthResponse, *jsonrpc.Error)
- func (svc *Service) Methods() map[jsonrpc.Method]rpcserver.MethodDef
- func (svc *Service) Name() string
- func (svc *Service) Tx(_ context.Context, req *chainjson.TxRequest) (*chainjson.TxResponse, *jsonrpc.Error)
- func (svc *Service) UnconfirmedTxs(_ context.Context, req *chainjson.UnconfirmedTxsRequest) (*chainjson.UnconfirmedTxsResponse, *jsonrpc.Error)
- func (svc *Service) Validators(_ context.Context, _ *chainjson.ValidatorsRequest) (*chainjson.ValidatorsResponse, *jsonrpc.Error)
- type Validators
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SpecInfo = openrpc.Info{ Title: "Kwil DB Chain service", Description: `The JSON-RPC chain service for Kwil DB.`, License: &openrpc.License{ Name: "CC0-1.0", URL: "https://creativecommons.org/publicdomain/zero/1.0/legalcode", }, Version: "0.1.0", } )
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node interface {
// BlockByHeight returns block info at height. If height=0, the latest block will be returned.
BlockByHeight(height int64) (ktypes.Hash, *ktypes.Block, *ktypes.CommitInfo, error)
BlockByHash(hash ktypes.Hash) (*ktypes.Block, *ktypes.CommitInfo, error)
RawBlockByHeight(height int64) (ktypes.Hash, []byte, *ktypes.CommitInfo, error)
RawBlockByHash(hash ktypes.Hash) ([]byte, *ktypes.CommitInfo, error)
BlockResultByHash(hash ktypes.Hash) ([]ktypes.TxResult, error)
ChainTx(hash ktypes.Hash) (*chaintypes.Tx, error)
BlockHeight() int64
ChainUnconfirmedTx(limit int) (int, []*nodetypes.Tx)
ConsensusParams() *ktypes.NetworkParameters
}
Node specifies the methods required for chain service to interact with the blockchain.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(log log.Logger, blockchain Node, voting Validators, genesisCfg *config.GenesisConfig) *Service
func (*Service) Block ¶
func (svc *Service) Block(_ context.Context, req *chainjson.BlockRequest) (*chainjson.BlockResponse, *jsonrpc.Error)
Block returns block information either by block height or block hash. If both provided, block hash will be used.
func (*Service) BlockResult ¶
func (svc *Service) BlockResult(_ context.Context, req *chainjson.BlockResultRequest) (*chainjson.BlockResultResponse, *jsonrpc.Error)
BlockResult returns block result either by block height or bloch hash. If both provided, block hash will be used.
func (*Service) ConsensusParams ¶
func (svc *Service) ConsensusParams(_ context.Context, _ *chainjson.ConsensusParamsRequest) (*chainjson.ConsensusParamsResponse, *jsonrpc.Error)
func (*Service) Genesis ¶
func (svc *Service) Genesis(ctx context.Context, _ *chainjson.GenesisRequest) (*chainjson.GenesisResponse, *jsonrpc.Error)
func (*Service) HealthMethod ¶
func (svc *Service) HealthMethod(_ context.Context, _ *chainjson.HealthRequest) (*chainjson.HealthResponse, *jsonrpc.Error)
func (*Service) Tx ¶
func (svc *Service) Tx(_ context.Context, req *chainjson.TxRequest) (*chainjson.TxResponse, *jsonrpc.Error)
Tx returns a transaction by hash.
func (*Service) UnconfirmedTxs ¶
func (svc *Service) UnconfirmedTxs(_ context.Context, req *chainjson.UnconfirmedTxsRequest) (*chainjson.UnconfirmedTxsResponse, *jsonrpc.Error)
UnconfirmedTxs returns the unconfirmed txs. Default return 10 txs, max return 50 txs.
func (*Service) Validators ¶
func (svc *Service) Validators(_ context.Context, _ *chainjson.ValidatorsRequest) (*chainjson.ValidatorsResponse, *jsonrpc.Error)
Validators returns validator set at the current height.
type Validators ¶
Click to show internal directories.
Click to hide internal directories.