Skip to content

Latest commit

 

History

History

ledger

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ledger

import "github.com/formancehq/ledger/internal/controller/ledger"

Ledger Controller doc

Index

Variables

var ErrNoPostings = errors.New("numscript execution returned no postings")

var ErrNotFound = postgres.ErrNotFound

type Balance

type Balance struct {
    Asset   string
    Balance *big.Int
}

type BalanceQuery = vm.BalanceQuery

type Balances = vm.Balances

type CacheConfiguration struct {
    MaxCount uint
}

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

func NewCachedCompiler(compiler Compiler, configuration CacheConfiguration) *CachedCompiler

func (*CachedCompiler) Compile

func (c *CachedCompiler) Compile(script string) (*program.Program, error)

Compiler can return following errors:

  • ErrCompilationFailed
type Compiler interface {
    Compile(script string) (*program.Program, error)
}

type CompilerFn func(script string) (*program.Program, error)

func NewDefaultCompiler() CompilerFn

func (CompilerFn) Compile

func (fn CompilerFn) Compile(script string) (*program.Program, error)

type Controller interface {
    // IsDatabaseUpToDate check if the ledger store is up to date, including the bucket and the ledger specifics
    // It returns true if up to date
    IsDatabaseUpToDate(ctx context.Context) (bool, error)
    GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error)
    GetStats(ctx context.Context) (Stats, error)

    GetAccount(ctx context.Context, query GetAccountQuery) (*ledger.Account, error)
    ListAccounts(ctx context.Context, query ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error)
    CountAccounts(ctx context.Context, query ListAccountsQuery) (int, error)
    ListLogs(ctx context.Context, query GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)
    CountTransactions(ctx context.Context, query ListTransactionsQuery) (int, error)
    ListTransactions(ctx context.Context, query ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error)
    GetTransaction(ctx context.Context, query GetTransactionQuery) (*ledger.Transaction, error)
    GetVolumesWithBalances(ctx context.Context, q GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error)
    GetAggregatedBalances(ctx context.Context, q GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error)

    // CreateTransaction accept a numscript script and returns a transaction
    // It can return following errors:
    //  * ErrCompilationFailed
    //  * ErrMetadataOverride
    //  * ErrInvalidVars
    //  * ErrTransactionReferenceConflict
    //  * ErrIdempotencyKeyConflict
    //  * ErrInsufficientFunds
    CreateTransaction(ctx context.Context, parameters Parameters[RunScript]) (*ledger.CreatedTransaction, error)
    // RevertTransaction allow to revert a transaction.
    // It can return following errors:
    //  * ErrInsufficientFunds
    //  * ErrAlreadyReverted
    //  * ErrNotFound
    // Parameter force indicate we want to force revert the transaction even if the accounts does not have funds
    // Parameter atEffectiveDate indicate we want to set the timestamp of the newly created transaction on the timestamp of the reverted transaction
    RevertTransaction(ctx context.Context, parameters Parameters[RevertTransaction]) (*ledger.RevertedTransaction, error)
    // SaveTransactionMetadata allow to add metadata to an existing transaction
    // It can return following errors:
    //  * ErrNotFound
    SaveTransactionMetadata(ctx context.Context, parameters Parameters[SaveTransactionMetadata]) error
    // SaveAccountMetadata allow to add metadata to an account
    // If the account does not exist, it is created
    SaveAccountMetadata(ctx context.Context, parameters Parameters[SaveAccountMetadata]) error
    // DeleteTransactionMetadata allow to remove metadata of a transaction
    // It can return following errors:
    //  * ErrNotFound : indicate the transaction was not found OR the metadata does not exist on the transaction
    DeleteTransactionMetadata(ctx context.Context, parameters Parameters[DeleteTransactionMetadata]) error
    // DeleteAccountMetadata allow to remove metadata of an account
    // It can return following errors:
    //  * ErrNotFound : indicate the account was not found OR the metadata does not exist on the account
    DeleteAccountMetadata(ctx context.Context, parameters Parameters[DeleteAccountMetadata]) error
    // Import allow to import the logs of an existing ledger
    // It can return following errors:
    //  * ErrImport
    // Logs hash must be valid and the ledger.Ledger must be in 'initializing' state
    Import(ctx context.Context, stream chan ledger.Log) error
    // Export allow to export the logs of a ledger
    Export(ctx context.Context, w ExportWriter) error
}

type ControllerWithCache struct {
    Controller
    // contains filtered or unexported fields
}

func NewControllerWithCache(ledger ledger.Ledger, underlying Controller, registry *StateRegistry) *ControllerWithCache

func (*ControllerWithCache) IsDatabaseUpToDate

func (c *ControllerWithCache) IsDatabaseUpToDate(ctx context.Context) (bool, error)

type ControllerWithEvents struct {
    Controller
    // contains filtered or unexported fields
}

func NewControllerWithEvents(ledger ledger.Ledger, underlying Controller, listener Listener) *ControllerWithEvents

func (*ControllerWithEvents) CreateTransaction

func (ctrl *ControllerWithEvents) CreateTransaction(ctx context.Context, parameters Parameters[RunScript]) (*ledger.CreatedTransaction, error)

func (*ControllerWithEvents) DeleteAccountMetadata

func (ctrl *ControllerWithEvents) DeleteAccountMetadata(ctx context.Context, parameters Parameters[DeleteAccountMetadata]) error

func (*ControllerWithEvents) DeleteTransactionMetadata

func (ctrl *ControllerWithEvents) DeleteTransactionMetadata(ctx context.Context, parameters Parameters[DeleteTransactionMetadata]) error

func (*ControllerWithEvents) RevertTransaction

func (ctrl *ControllerWithEvents) RevertTransaction(ctx context.Context, parameters Parameters[RevertTransaction]) (*ledger.RevertedTransaction, error)

func (*ControllerWithEvents) SaveAccountMetadata

func (ctrl *ControllerWithEvents) SaveAccountMetadata(ctx context.Context, parameters Parameters[SaveAccountMetadata]) error

func (*ControllerWithEvents) SaveTransactionMetadata

func (ctrl *ControllerWithEvents) SaveTransactionMetadata(ctx context.Context, parameters Parameters[SaveTransactionMetadata]) error

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

func NewControllerWithTraces(underlying Controller) *ControllerWithTraces

func (*ControllerWithTraces) CountAccounts

func (ctrl *ControllerWithTraces) CountAccounts(ctx context.Context, a ListAccountsQuery) (int, error)

func (*ControllerWithTraces) CountTransactions

func (ctrl *ControllerWithTraces) CountTransactions(ctx context.Context, q ListTransactionsQuery) (int, error)

func (*ControllerWithTraces) CreateTransaction

func (ctrl *ControllerWithTraces) CreateTransaction(ctx context.Context, parameters Parameters[RunScript]) (*ledger.CreatedTransaction, error)

func (*ControllerWithTraces) DeleteAccountMetadata

func (ctrl *ControllerWithTraces) DeleteAccountMetadata(ctx context.Context, parameters Parameters[DeleteAccountMetadata]) error

func (*ControllerWithTraces) DeleteTransactionMetadata

func (ctrl *ControllerWithTraces) DeleteTransactionMetadata(ctx context.Context, parameters Parameters[DeleteTransactionMetadata]) error

func (*ControllerWithTraces) Export

func (ctrl *ControllerWithTraces) Export(ctx context.Context, w ExportWriter) error

func (*ControllerWithTraces) GetAccount

func (ctrl *ControllerWithTraces) GetAccount(ctx context.Context, q GetAccountQuery) (*ledger.Account, error)

func (*ControllerWithTraces) GetAggregatedBalances

func (ctrl *ControllerWithTraces) GetAggregatedBalances(ctx context.Context, q GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error)

func (*ControllerWithTraces) GetMigrationsInfo

func (ctrl *ControllerWithTraces) GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error)

func (*ControllerWithTraces) GetStats

func (ctrl *ControllerWithTraces) GetStats(ctx context.Context) (Stats, error)

func (*ControllerWithTraces) GetTransaction

func (ctrl *ControllerWithTraces) GetTransaction(ctx context.Context, query GetTransactionQuery) (*ledger.Transaction, error)

func (*ControllerWithTraces) GetVolumesWithBalances

func (ctrl *ControllerWithTraces) GetVolumesWithBalances(ctx context.Context, q GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error)

func (*ControllerWithTraces) Import

func (ctrl *ControllerWithTraces) Import(ctx context.Context, stream chan ledger.Log) error

func (*ControllerWithTraces) IsDatabaseUpToDate

func (ctrl *ControllerWithTraces) IsDatabaseUpToDate(ctx context.Context) (bool, error)

func (*ControllerWithTraces) ListAccounts

func (ctrl *ControllerWithTraces) ListAccounts(ctx context.Context, a ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error)

func (*ControllerWithTraces) ListLogs

func (ctrl *ControllerWithTraces) ListLogs(ctx context.Context, q GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)

func (*ControllerWithTraces) ListTransactions

func (ctrl *ControllerWithTraces) ListTransactions(ctx context.Context, q ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error)

func (*ControllerWithTraces) RevertTransaction

func (ctrl *ControllerWithTraces) RevertTransaction(ctx context.Context, parameters Parameters[RevertTransaction]) (*ledger.RevertedTransaction, error)

func (*ControllerWithTraces) SaveAccountMetadata

func (ctrl *ControllerWithTraces) SaveAccountMetadata(ctx context.Context, parameters Parameters[SaveAccountMetadata]) error

func (*ControllerWithTraces) SaveTransactionMetadata

func (ctrl *ControllerWithTraces) SaveTransactionMetadata(ctx context.Context, parameters Parameters[SaveTransactionMetadata]) error

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

func NewDefaultController(ledger ledger.Ledger, store Store, machineFactory MachineFactory) *DefaultController

func (*DefaultController) CountAccounts

func (ctrl *DefaultController) CountAccounts(ctx context.Context, a ListAccountsQuery) (int, error)

func (*DefaultController) CountTransactions

func (ctrl *DefaultController) CountTransactions(ctx context.Context, q ListTransactionsQuery) (int, error)

func (*DefaultController) CreateTransaction

func (ctrl *DefaultController) CreateTransaction(ctx context.Context, parameters Parameters[RunScript]) (*ledger.CreatedTransaction, error)

func (*DefaultController) DeleteAccountMetadata

func (ctrl *DefaultController) DeleteAccountMetadata(ctx context.Context, parameters Parameters[DeleteAccountMetadata]) error

func (*DefaultController) DeleteTransactionMetadata

func (ctrl *DefaultController) DeleteTransactionMetadata(ctx context.Context, parameters Parameters[DeleteTransactionMetadata]) error

func (*DefaultController) Export

func (ctrl *DefaultController) Export(ctx context.Context, w ExportWriter) error

func (*DefaultController) GetAccount

func (ctrl *DefaultController) GetAccount(ctx context.Context, q GetAccountQuery) (*ledger.Account, error)

func (*DefaultController) GetAggregatedBalances

func (ctrl *DefaultController) GetAggregatedBalances(ctx context.Context, q GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error)

func (*DefaultController) GetMigrationsInfo

func (ctrl *DefaultController) GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error)

func (*DefaultController) GetStats

func (ctrl *DefaultController) GetStats(ctx context.Context) (Stats, error)

func (*DefaultController) GetTransaction

func (ctrl *DefaultController) GetTransaction(ctx context.Context, query GetTransactionQuery) (*ledger.Transaction, error)

func (*DefaultController) GetVolumesWithBalances

func (ctrl *DefaultController) GetVolumesWithBalances(ctx context.Context, q GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error)

func (*DefaultController) Import

func (ctrl *DefaultController) Import(ctx context.Context, stream chan ledger.Log) error

func (*DefaultController) IsDatabaseUpToDate

func (ctrl *DefaultController) IsDatabaseUpToDate(ctx context.Context) (bool, error)

func (*DefaultController) ListAccounts

func (ctrl *DefaultController) ListAccounts(ctx context.Context, a ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error)

func (*DefaultController) ListLogs

func (ctrl *DefaultController) ListLogs(ctx context.Context, q GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)

func (*DefaultController) ListTransactions

func (ctrl *DefaultController) ListTransactions(ctx context.Context, q ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error)

func (*DefaultController) RevertTransaction

func (ctrl *DefaultController) RevertTransaction(ctx context.Context, parameters Parameters[RevertTransaction]) (*ledger.RevertedTransaction, error)

func (*DefaultController) SaveAccountMetadata

func (ctrl *DefaultController) SaveAccountMetadata(ctx context.Context, parameters Parameters[SaveAccountMetadata]) error

func (*DefaultController) SaveTransactionMetadata

func (ctrl *DefaultController) SaveTransactionMetadata(ctx context.Context, parameters Parameters[SaveTransactionMetadata]) error

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

func NewDefaultMachine(p program.Program) *DefaultMachineAdapter

func (*DefaultMachineAdapter) Execute

func (d *DefaultMachineAdapter) Execute(ctx context.Context, tx TX, vars map[string]string) (*MachineResult, error)

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

func NewDefaultMachineFactory(compiler Compiler) *DefaultMachineFactory

func (*DefaultMachineFactory) Make

func (d *DefaultMachineFactory) Make(script string) (Machine, error)

type DeleteAccountMetadata struct {
    Address string
    Key     string
}

type DeleteTransactionMetadata struct {
    TransactionID int
    Key           string
}

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

func (ErrAlreadyReverted) Error

func (e ErrAlreadyReverted) Error() string

func (ErrAlreadyReverted) Is

func (e ErrAlreadyReverted) Is(err error) bool

ErrCompilationFailed is used for any errors returned by the numscript interpreter

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

func (ErrCompilationFailed) Error

func (e ErrCompilationFailed) Error() string

func (ErrCompilationFailed) Is

func (e ErrCompilationFailed) Is(err error) bool

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

func NewErrIdempotencyKeyConflict(ik string) ErrIdempotencyKeyConflict

func (ErrIdempotencyKeyConflict) Error

func (e ErrIdempotencyKeyConflict) Error() string

func (ErrIdempotencyKeyConflict) Is

func (e ErrIdempotencyKeyConflict) Is(err error) bool

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

func (ErrImport) Error

func (i ErrImport) Error() string

func (ErrImport) Is

func (i ErrImport) Is(err error) bool

todo(waiting): need a more precise underlying error notes(gfyrag): Waiting new interpreter

type ErrInsufficientFunds = machine.ErrInsufficientFund

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

func (ErrInvalidHash) Error

func (i ErrInvalidHash) Error() string

ErrInvalidIdempotencyInput is used when a IK is used with an inputs different from the original one. For example, try to use the same IK with a different numscript script will result with that error.

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

func (ErrInvalidIdempotencyInput) Error

func (e ErrInvalidIdempotencyInput) Error() string

func (ErrInvalidIdempotencyInput) Is

func (e ErrInvalidIdempotencyInput) Is(err error) bool

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

func NewErrInvalidQuery(msg string, args ...any) ErrInvalidQuery

func (ErrInvalidQuery) Error

func (e ErrInvalidQuery) Error() string

func (ErrInvalidQuery) Is

func (e ErrInvalidQuery) Is(err error) bool

type ErrInvalidVars = machine.ErrInvalidVars

ErrMetadataOverride is used when a metadata is defined at numscript level AND at the input level

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

func (*ErrMetadataOverride) Error

func (e *ErrMetadataOverride) Error() string

func (*ErrMetadataOverride) Is

func (e *ErrMetadataOverride) Is(err error) bool

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

func NewErrMissingFeature(feature string) ErrMissingFeature

func (ErrMissingFeature) Error

func (e ErrMissingFeature) Error() string

func (ErrMissingFeature) Is

func (e ErrMissingFeature) Is(err error) bool

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

func NewErrTransactionReferenceConflict(reference string) ErrTransactionReferenceConflict

func (ErrTransactionReferenceConflict) Error

func (e ErrTransactionReferenceConflict) Error() string

func (ErrTransactionReferenceConflict) Is

func (e ErrTransactionReferenceConflict) Is(err error) bool

type ExportWriter interface {
    Write(ctx context.Context, log ledger.Log) error
}

type ExportWriterFn func(ctx context.Context, log ledger.Log) error

func (ExportWriterFn) Write

func (fn ExportWriterFn) Write(ctx context.Context, log ledger.Log) error

type FiltersForVolumes struct {
    PITFilter
    UseInsertionDate bool
    GroupLvl         int
}

type GetAccountQuery struct {
    PITFilterWithVolumes
    Addr string
}

func NewGetAccountQuery(addr string) GetAccountQuery

func (GetAccountQuery) WithExpandEffectiveVolumes

func (q GetAccountQuery) WithExpandEffectiveVolumes() GetAccountQuery

func (GetAccountQuery) WithExpandVolumes

func (q GetAccountQuery) WithExpandVolumes() GetAccountQuery

func (GetAccountQuery) WithPIT

func (q GetAccountQuery) WithPIT(pit time.Time) GetAccountQuery

type GetAggregatedBalanceQuery struct {
    PITFilter
    QueryBuilder     query.Builder
    UseInsertionDate bool
}

func NewGetAggregatedBalancesQuery(filter PITFilter, qb query.Builder, useInsertionDate bool) GetAggregatedBalanceQuery

type GetLogsQuery bunpaginate.ColumnPaginatedQuery[PaginatedQueryOptions[any]]

func NewListLogsQuery(options PaginatedQueryOptions[any]) GetLogsQuery

func (GetLogsQuery) WithOrder

func (q GetLogsQuery) WithOrder(order bunpaginate.Order) GetLogsQuery

type GetTransactionQuery struct {
    PITFilterWithVolumes
    ID  int
}

func NewGetTransactionQuery(id int) GetTransactionQuery

func (GetTransactionQuery) WithExpandEffectiveVolumes

func (q GetTransactionQuery) WithExpandEffectiveVolumes() GetTransactionQuery

func (GetTransactionQuery) WithExpandVolumes

func (q GetTransactionQuery) WithExpandVolumes() GetTransactionQuery

type GetVolumesWithBalancesQuery bunpaginate.OffsetPaginatedQuery[PaginatedQueryOptions[FiltersForVolumes]]

func NewGetVolumesWithBalancesQuery(opts PaginatedQueryOptions[FiltersForVolumes]) GetVolumesWithBalancesQuery

type ListAccountsQuery bunpaginate.OffsetPaginatedQuery[PaginatedQueryOptions[PITFilterWithVolumes]]

func NewListAccountsQuery(opts PaginatedQueryOptions[PITFilterWithVolumes]) ListAccountsQuery

func (ListAccountsQuery) WithExpandEffectiveVolumes

func (q ListAccountsQuery) WithExpandEffectiveVolumes() ListAccountsQuery

func (ListAccountsQuery) WithExpandVolumes

func (q ListAccountsQuery) WithExpandVolumes() ListAccountsQuery

type ListLedgersQuery bunpaginate.OffsetPaginatedQuery[PaginatedQueryOptions[struct{}]]

func NewListLedgersQuery(pageSize uint64) ListLedgersQuery

type ListTransactionsQuery bunpaginate.ColumnPaginatedQuery[PaginatedQueryOptions[PITFilterWithVolumes]]

func NewListTransactionsQuery(options PaginatedQueryOptions[PITFilterWithVolumes]) ListTransactionsQuery

func (ListTransactionsQuery) WithColumn

func (q ListTransactionsQuery) WithColumn(column string) ListTransactionsQuery

type Listener interface {
    CommittedTransactions(ctx context.Context, ledger string, res ledger.Transaction, accountMetadata ledger.AccountMetadata)
    SavedMetadata(ctx context.Context, ledger string, targetType, id string, metadata metadata.Metadata)
    RevertedTransaction(ctx context.Context, ledger string, reverted, revert ledger.Transaction)
    DeletedMetadata(ctx context.Context, ledger string, targetType string, targetID any, key string)
}

type Machine

type Machine interface {
    Execute(context.Context, TX, map[string]string) (*MachineResult, error)
}

type MachineFactory interface {
    // Make can return following errors:
    //  * ErrCompilationFailed
    Make(script string) (Machine, error)
}

type MachineResult struct {
    Postings        ledger.Postings   `json:"postings"`
    Metadata        metadata.Metadata `json:"metadata"`
    AccountMetadata map[string]metadata.Metadata
}

type PITFilter struct {
    PIT *time.Time `json:"pit"`
    OOT *time.Time `json:"oot"`
}

type PITFilterWithVolumes struct {
    PITFilter
    ExpandVolumes          bool `json:"volumes"`
    ExpandEffectiveVolumes bool `json:"effectiveVolumes"`
}

type PaginatedQueryOptions[T any] struct {
    QueryBuilder query.Builder `json:"qb"`
    PageSize     uint64        `json:"pageSize"`
    Options      T             `json:"options"`
}

func NewPaginatedQueryOptions[T any](options T) PaginatedQueryOptions[T]

func (*PaginatedQueryOptions[T]) UnmarshalJSON

func (opts *PaginatedQueryOptions[T]) UnmarshalJSON(data []byte) error

func (PaginatedQueryOptions[T]) WithPageSize

func (opts PaginatedQueryOptions[T]) WithPageSize(pageSize uint64) PaginatedQueryOptions[T]

func (PaginatedQueryOptions[T]) WithQueryBuilder

func (opts PaginatedQueryOptions[T]) WithQueryBuilder(qb query.Builder) PaginatedQueryOptions[T]

type Parameters[INPUT any] struct {
    DryRun         bool
    IdempotencyKey string
    Input          INPUT
}

type RevertTransaction struct {
    Force           bool
    AtEffectiveDate bool
    TransactionID   int
}

type RunScript = vm.RunScript

type SaveAccountMetadata struct {
    Address  string
    Metadata metadata.Metadata
}

type SaveTransactionMetadata struct {
    TransactionID int
    Metadata      metadata.Metadata
}

type Script

type Script = vm.Script

type ScriptV1 = vm.ScriptV1

type State

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

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

func NewStateRegistry() *StateRegistry

func (*StateRegistry) IsUpToDate

func (r *StateRegistry) IsUpToDate(name string) bool

func (*StateRegistry) SetUpToDate

func (r *StateRegistry) SetUpToDate(name string)

func (*StateRegistry) Upsert

func (r *StateRegistry) Upsert(l ledger.Ledger) bool

type Stats

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

type Store

type Store interface {
    WithTX(context.Context, *sql.TxOptions, func(TX) (bool, error)) error
    GetDB() bun.IDB
    ListLogs(ctx context.Context, q GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)
    ReadLogWithIdempotencyKey(ctx context.Context, ik string) (*ledger.Log, error)

    ListTransactions(ctx context.Context, q ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error)
    CountTransactions(ctx context.Context, q ListTransactionsQuery) (int, error)
    GetTransaction(ctx context.Context, query GetTransactionQuery) (*ledger.Transaction, error)
    CountAccounts(ctx context.Context, a ListAccountsQuery) (int, error)
    ListAccounts(ctx context.Context, a ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error)
    GetAccount(ctx context.Context, q GetAccountQuery) (*ledger.Account, error)
    GetAggregatedBalances(ctx context.Context, q GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error)
    GetVolumesWithBalances(ctx context.Context, q GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error)
    IsUpToDate(ctx context.Context) (bool, error)
    GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error)
}

type TX

type TX interface {
    GetAccount(ctx context.Context, query GetAccountQuery) (*ledger.Account, error)
    // GetBalances must returns balance and lock account until the end of the TX
    GetBalances(ctx context.Context, query BalanceQuery) (Balances, error)
    CommitTransaction(ctx context.Context, transaction *ledger.Transaction) error
    // RevertTransaction revert the transaction with identifier id
    // It returns :
    //  * the reverted transaction
    //  * a boolean indicating if the transaction has been reverted. false indicates an already reverted transaction (unless error != nil)
    //  * an error
    RevertTransaction(ctx context.Context, id int) (*ledger.Transaction, bool, error)
    UpdateTransactionMetadata(ctx context.Context, transactionID int, m metadata.Metadata) (*ledger.Transaction, bool, error)
    DeleteTransactionMetadata(ctx context.Context, transactionID int, key string) (*ledger.Transaction, bool, error)
    UpdateAccountsMetadata(ctx context.Context, m map[string]metadata.Metadata) error
    // UpsertAccount returns a boolean indicating if the account was upserted
    UpsertAccount(ctx context.Context, account *ledger.Account) (bool, error)
    DeleteAccountMetadata(ctx context.Context, address, key string) error
    InsertLog(ctx context.Context, log *ledger.Log) error

    LockLedger(ctx context.Context) error
    ListLogs(ctx context.Context, q GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)
}

Generated by gomarkdoc