datasets

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInsufficientFee      = errors.New("insufficient fee")
	ErrAuthenticationFailed = errors.New("authentication failed")
)

Functions

func ConvertSchemaToEngine

func ConvertSchemaToEngine(old *transactions.Schema) (*engineTypes.Schema, error)

Types

type AccountStore

type AccountStore interface {
	Spend(ctx context.Context, spend *accounts.Spend) error
}

type DatabaseUseCaseOpt

type DatabaseUseCaseOpt func(*DatasetModule)

func WithFeeMultiplier

func WithFeeMultiplier(multiplier int64) DatabaseUseCaseOpt

WithFeeMultiplier sets the fee multiplier pricing

func WithLogger

func WithLogger(logger log.Logger) DatabaseUseCaseOpt

WithLogger sets the logger

type DatasetModule

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

func NewDatasetModule

func NewDatasetModule(engine Engine, accountStore AccountStore, opts ...DatabaseUseCaseOpt) *DatasetModule

func (*DatasetModule) Call

func (u *DatasetModule) Call(ctx context.Context, dbid string, action string, args []any, msg *transactions.CallMessage) ([]map[string]any, error)

Call executes a call action on a database. It is a read-only action. It returns the result of the call. If a message caller is specified, then it will check the signature of the message and use the caller as the caller of the action.

func (*DatasetModule) Deploy

Deploy deploys a database.

func (*DatasetModule) Drop

Drop drops a database.

func (*DatasetModule) Execute

func (u *DatasetModule) Execute(ctx context.Context, dbid string, action string, args [][]any, tx *transactions.Transaction) (*ExecutionResponse, error)

Execute executes an action against a database.

func (*DatasetModule) GetSchema

func (u *DatasetModule) GetSchema(ctx context.Context, dbid string) (*engineTypes.Schema, error)

GetSchema returns the schema of a database.

func (*DatasetModule) ListOwnedDatabases

func (u *DatasetModule) ListOwnedDatabases(ctx context.Context, owner []byte) ([]*coreTypes.DatasetIdentifier, error)

ListOwnedDatabase returns a list of databases owned by a public key.

func (*DatasetModule) PriceDeploy

func (d *DatasetModule) PriceDeploy(ctx context.Context, schema *engineTypes.Schema) (price *big.Int, err error)

PriceDeploy returns the price of deploying a schema.

func (*DatasetModule) PriceDrop

func (d *DatasetModule) PriceDrop(ctx context.Context, dbid string) (price *big.Int, err error)

PriceDrop returns the price of dropping a schema.

func (*DatasetModule) PriceExecute

func (d *DatasetModule) PriceExecute(ctx context.Context, dbid string, action string, args [][]any) (price *big.Int, err error)

PriceExecute returns the price of executing an action.

func (*DatasetModule) Query

func (u *DatasetModule) Query(ctx context.Context, dbid string, query string) ([]map[string]any, error)

Query executes an ad-hoc query on a database. It is a read-only action. It returns the result of the query.

type Engine

type Engine interface {
	CreateDataset(ctx context.Context, schema *types.Schema, caller []byte) (err error)
	DeleteDataset(ctx context.Context, dbid string, caller []byte) error
	Execute(ctx context.Context, data *types.ExecutionData) (*sql.ResultSet, error)
	GetSchema(ctx context.Context, dbid string) (*types.Schema, error)
	ListDatasets(ctx context.Context, caller []byte) ([]*coreTypes.DatasetIdentifier, error)
	Query(ctx context.Context, dbid string, query string) (*sql.ResultSet, error)
}

type ExecutionResponse

type ExecutionResponse struct {
	// Fee is the amount of tokens spent on the execution
	Fee     *big.Int
	GasUsed int64 // ?
}

ExecutionResponse is the response from any interaction that modifies state.

Jump to

Keyboard shortcuts

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