chainsvc

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

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

Block returns block information either by block height or block hash. If both provided, block hash will be used.

func (*Service) BlockResult

BlockResult returns block result either by block height or bloch hash. If both provided, block hash will be used.

func (*Service) Genesis

func (*Service) Health

func (svc *Service) Health(ctx context.Context) (detail json.RawMessage, happy bool)

func (*Service) HealthMethod

func (*Service) Methods

func (svc *Service) Methods() map[jsonrpc.Method]rpcserver.MethodDef

func (*Service) Name

func (svc *Service) Name() string

func (*Service) Tx

Tx returns a transaction by hash.

func (*Service) UnconfirmedTxs

UnconfirmedTxs returns the unconfirmed txs. Default return 10 txs, max return 50 txs.

func (*Service) Validators

Validators returns validator set at the current height.

type Validators

type Validators interface {
	GetValidators() []*ktypes.Validator
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL