usersvc

package
v0.10.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SpecInfo = openrpc.Info{
		Title:       "Kwil DB user service",
		Description: `The JSON-RPC user service for Kwil DB.`,
		License: &openrpc.License{
			Name: "CC0-1.0",
			URL:  "https://creativecommons.org/publicdomain/zero/1.0/legalcode",
		},
		Version: "0.2.0",
	}
)

Functions

This section is empty.

Types

type BlockchainTransactor

type BlockchainTransactor interface {
	Status(ctx context.Context) (*adminTypes.Status, error)
	Peers(context.Context) ([]*adminTypes.PeerInfo, error)
	ConsensusParams() *types.NetworkParameters
	BroadcastTx(ctx context.Context, tx *types.Transaction, sync uint8) (types.Hash, *types.TxResult, error)
	TxQuery(ctx context.Context, hash types.Hash, prove bool) (*types.TxQueryResponse, error)
}

type DB

type DB interface {
	sql.ReadTxMaker
	sql.DelayedReadTxMaker
}

type EngineReader

type EngineReader interface {
	Call(ctx *common.EngineContext, tx sql.DB, namespace, action string, args []any, resultFn func(*common.Row) error) (*common.CallResult, error)
	Execute(ctx *common.EngineContext, tx sql.DB, query string, params map[string]any, resultFn func(*common.Row) error) error
}

type Migrator

type Migrator interface {
	GetChangesetMetadata(height int64) (*migrations.ChangesetMetadata, error)
	GetChangeset(height int64, index int64) ([]byte, error)
	GetGenesisSnapshotChunk(chunkIdx uint32) ([]byte, error)
}

type NodeApp

type NodeApp interface {
	AccountInfo(ctx context.Context, db sql.DB, account *types.AccountID, pending bool) (balance *big.Int, nonce int64, err error)
	NumAccounts(ctx context.Context, db sql.Executor) (count, height int64, err error)
	Price(ctx context.Context, dbTx sql.DB, tx *types.Transaction) (*big.Int, error)
	GetMigrationMetadata(ctx context.Context) (*types.MigrationMetadata, error)
}

type Opt

type Opt func(*serviceCfg)

Opt is a Service option.

func WithBlockAgeHealth

func WithBlockAgeHealth(ageThresh time.Duration) Opt

func WithChallengeExpiry

func WithChallengeExpiry(expiry time.Duration) Opt

func WithChallengeRateLimit

func WithChallengeRateLimit(limit float64) Opt

func WithPrivateMode

func WithPrivateMode(privateMode bool) Opt

func WithReadTxTimeout

func WithReadTxTimeout(timeout time.Duration) Opt

WithReadTxTimeout sets a timeout for read-only DB transactions, as used by the Query and Call methods of Service.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the "user" RPC service, also known as txsvc in other contexts.

func NewService

func NewService(db DB, engine EngineReader, chainClient BlockchainTransactor,
	nodeApp NodeApp, vals Validators, migrator Migrator, logger log.Logger, opts ...Opt) *Service

NewService creates a new instance of the user RPC service.

func (*Service) Account

func (*Service) AuthenticatedQuery

func (*Service) Broadcast

func (*Service) Call

func (*Service) CallChallenge

CallChallenge is the handler for the user.challenge RPC. It gives the user a new challenge for use with a signed call request. They are single use, and they expire according to the service's challenge expiry configuration.

func (*Service) ChainInfo

func (*Service) EstimatePrice

func (*Service) Handlers

func (svc *Service) Handlers() map[jsonrpc.Method]rpcserver.MethodHandler

func (*Service) Health

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

Health for the user service responds with details from publicly available information from the chain_info response such as best block age. The health boolean also considers node state.

func (*Service) HealthMethod

HealthMethod is a JSON-RPC method handler for service health.

func (*Service) ListPendingMigrations

func (*Service) LoadChangeset

func (*Service) Methods

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

func (*Service) Name

func (svc *Service) Name() string

func (*Service) NumAccounts

func (*Service) Ping

func (*Service) Query

func (*Service) TxQuery

type Validators

type Validators interface {
	GetValidatorPower(ctx context.Context, pubKey []byte, pubKeyType crypto.KeyType) (int64, error)
	GetValidators() []*types.Validator
}

Jump to

Keyboard shortcuts

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