ledger

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ResolverOptionsKey = `group:"_ledgerResolverOptions"`

Variables

View Source
var DefaultContracts = []core.Contract{
	{
		Expr: &core.ExprGte{
			Op1: core.VariableExpr{
				Name: "balance",
			},
			Op2: core.ConstantExpr{
				Value: float64(0),
			},
		},
		Account: "*",
	},
}
View Source
var ErrCommitError = errors.New("commit error")

Functions

func ProvideResolverOption

func ProvideResolverOption(provider interface{}) fx.Option

func ResolveModule

func ResolveModule() fx.Option

Types

type Balances

type Balances map[string]map[string]int64

type CommitTransactionResult

type CommitTransactionResult struct {
	core.Transaction
	Err *TransactionCommitError `json:"error,omitempty"`
}

type ConflictError

type ConflictError struct {
	Reference string
}

func NewConflictError

func NewConflictError(ref string) *ConflictError

func (ConflictError) Error

func (e ConflictError) Error() string

type InMemoryLocker

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

func NewInMemoryLocker

func NewInMemoryLocker() *InMemoryLocker

func (*InMemoryLocker) Lock

func (d *InMemoryLocker) Lock(ctx context.Context, ledger string) (Unlock, error)

type InsufficientFundError

type InsufficientFundError struct {
	Asset string
}

func NewInsufficientFundError

func NewInsufficientFundError(asset string) *InsufficientFundError

func (InsufficientFundError) Error

func (e InsufficientFundError) Error() string

type Ledger

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

func NewLedger

func NewLedger(name string, store storage.Store, locker Locker) (*Ledger, error)

func (*Ledger) Close

func (l *Ledger) Close(ctx context.Context) error

func (*Ledger) Commit

func (*Ledger) Execute

func (l *Ledger) Execute(ctx context.Context, script core.Script) error

func (*Ledger) FindAccounts

func (l *Ledger) FindAccounts(ctx context.Context, m ...query.QueryModifier) (query.Cursor, error)

func (*Ledger) FindTransactions

func (l *Ledger) FindTransactions(ctx context.Context, m ...query.QueryModifier) (query.Cursor, error)

func (*Ledger) GetAccount

func (l *Ledger) GetAccount(ctx context.Context, address string) (core.Account, error)

func (*Ledger) GetLastTransaction

func (l *Ledger) GetLastTransaction(ctx context.Context) (core.Transaction, error)

func (*Ledger) GetTransaction

func (l *Ledger) GetTransaction(ctx context.Context, id string) (core.Transaction, error)

func (*Ledger) LoadMapping

func (l *Ledger) LoadMapping(ctx context.Context) (*core.Mapping, error)

func (*Ledger) RevertTransaction

func (l *Ledger) RevertTransaction(ctx context.Context, id string) error

func (*Ledger) SaveMapping

func (l *Ledger) SaveMapping(ctx context.Context, mapping core.Mapping) error

func (*Ledger) SaveMeta

func (l *Ledger) SaveMeta(ctx context.Context, targetType string, targetID string, m core.Metadata) error

func (*Ledger) Stats

func (l *Ledger) Stats(ctx context.Context) (Stats, error)

func (*Ledger) Verify

func (l *Ledger) Verify() error

type Locker

type Locker interface {
	Lock(ctx context.Context, name string) (Unlock, error)
}

type ResolveOptionFn

type ResolveOptionFn func(r *Resolver) error

func WithLocker

func WithLocker(locker Locker) ResolveOptionFn

func WithLogger

func WithLogger(logger logging.Logger) ResolveOptionFn

func WithStorageFactory

func WithStorageFactory(factory storage.Factory) ResolveOptionFn

type Resolver

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

func NewResolver

func NewResolver(options ...ResolverOption) *Resolver

func (*Resolver) GetLedger

func (r *Resolver) GetLedger(ctx context.Context, name string) (*Ledger, error)

type ResolverOption

type ResolverOption interface {
	// contains filtered or unexported methods
}

type Stats

type Stats struct {
	Transactions int64 `json:"transactions"`
	Accounts     int64 `json:"accounts"`
}

type TransactionCommitError

type TransactionCommitError struct {
	TXIndex int   `json:"index"`
	Err     error `json:"error"`
}

func NewTransactionCommitError

func NewTransactionCommitError(txIndex int, err error) *TransactionCommitError

func (TransactionCommitError) Error

func (e TransactionCommitError) Error() string

type Unlock

type Unlock func(ctx context.Context)

type ValidationError

type ValidationError struct {
	Msg string
}

func NewValidationError

func NewValidationError(msg string) *ValidationError

func (ValidationError) Error

func (v ValidationError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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