light

package
v1.2.10-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 29 Imported by: 6

Documentation

Overview

Package light implements an Accumulate light client.

THIS PACKAGE IS EXPERIMENTAL AND SUBJECT TO CHANGE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByAnchorBlock

func ByAnchorBlock(block uint64) func(*AnchorMetadata) bool

ByAnchorBlock searches for an anchor entry with protocol.AnchorMetadata.MinorBlockIndex equal to or greater than the given value.

func ByIndexBlock

func ByIndexBlock(block uint64) func(*protocol.IndexEntry) bool

ByIndexBlock searches for an index entry with protocol.IndexEntry.BlockIndex equal to or greater than the given value.

func ByIndexRootIndexIndex

func ByIndexRootIndexIndex(rootIndex uint64) func(*protocol.IndexEntry) bool

ByIndexRootIndexIndex searches for an index entry with protocol.IndexEntry.RootIndexIndex equal to or greater than the given value.

func ByIndexSource

func ByIndexSource(source uint64) func(*protocol.IndexEntry) bool

ByIndexSource searches for an index entry with protocol.IndexEntry.Source equal to or greater than the given value.

func FindEntry

func FindEntry[T any](entries []T, fn func(T) bool) (int, T, bool)

FindEntry returns the index and value of the first entry for which the predicate is true, assuming it is false for some (possibly empty) prefix and true for the remainder of the entries.

Types

type AnchorMetadata

type AnchorMetadata struct {
	Index  uint64                    `json:"index,omitempty" form:"index" query:"index" validate:"required"`
	Hash   [32]byte                  `json:"hash,omitempty" form:"hash" query:"hash" validate:"required"`
	Anchor *protocol.PartitionAnchor `json:"anchor,omitempty" form:"anchor" query:"anchor" validate:"required"`
	// contains filtered or unexported fields
}

func (*AnchorMetadata) Copy

func (v *AnchorMetadata) Copy() *AnchorMetadata

func (*AnchorMetadata) CopyAsInterface

func (v *AnchorMetadata) CopyAsInterface() interface{}

func (*AnchorMetadata) Equal

func (v *AnchorMetadata) Equal(u *AnchorMetadata) bool

func (*AnchorMetadata) IsValid

func (v *AnchorMetadata) IsValid() error

func (*AnchorMetadata) MarshalBinary

func (v *AnchorMetadata) MarshalBinary() ([]byte, error)

func (*AnchorMetadata) MarshalJSON

func (v *AnchorMetadata) MarshalJSON() ([]byte, error)

func (*AnchorMetadata) UnmarshalBinary

func (v *AnchorMetadata) UnmarshalBinary(data []byte) error

func (*AnchorMetadata) UnmarshalBinaryFrom

func (v *AnchorMetadata) UnmarshalBinaryFrom(rd io.Reader) error

func (*AnchorMetadata) UnmarshalJSON

func (v *AnchorMetadata) UnmarshalJSON(b []byte) error

type Client

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

Client is a light client instance.

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

NewClient creates a new light client instance.

func (*Client) Close

func (c *Client) Close() error

Close frees any resources opened by the light client.

func (*Client) IndexAccountChains

func (c *Client) IndexAccountChains(ctx context.Context, acctUrl *url.URL) error

IndexAccountChains collates the index chain entries for an account's chains.

func (*Client) IndexAccountTransactions

func (c *Client) IndexAccountTransactions(ctx context.Context, accounts ...*url.URL) error

IndexAccountTransaction indexes the local and directory block index and time for the accounts' main chain transactions.

func (*Client) IndexAnchors

func (c *Client) IndexAnchors(ctx context.Context, partUrl *url.URL) error

IndexAnchors collates a partition's block anchors.

func (*Client) OpenDB

func (c *Client) OpenDB(writable bool) *DB

OpenDB opens a DB.

func (*Client) PullAccount

func (c *Client) PullAccount(ctx context.Context, acctUrl *url.URL) error

PullAccount fetches the latest version of the account and its chains.

func (*Client) PullMessagesForAccount added in v1.2.0

func (c *Client) PullMessagesForAccount(ctx context.Context, account *url.URL, chains ...string) error

func (*Client) PullPendingTransactionsForAccount

func (c *Client) PullPendingTransactionsForAccount(ctx context.Context, account *url.URL) error

func (*Client) PullTransactions

func (c *Client) PullTransactions(ctx context.Context, txids ...*url.TxID) error

PullTransaction fetches a set of transactions.

func (*Client) PullTransactionsForAccount

func (c *Client) PullTransactionsForAccount(ctx context.Context, account *url.URL, chains ...string) error

PullTransactionsForAccount fetches transactions from the account's chains.

type ClientOption

type ClientOption func(c *Client) error

func BadgerStore

func BadgerStore(filepath string) ClientOption

func ClientV2

func ClientV2(client *client.Client) ClientOption

func Logger

func Logger(logger log.Logger, keyVals ...any) ClientOption

func MemoryStore

func MemoryStore() ClientOption

func Querier added in v1.2.0

func Querier(querier api.Querier) ClientOption

func Server

func Server(server string) ClientOption

func Store

func Store(s keyvalue.Beginner, prefix string) ClientOption

type DB

type DB struct {
	*database.Batch
	// contains filtered or unexported fields
}

DB is the light client database.

func (*DB) Commit

func (db *DB) Commit() error

Commit commits changes to the database.

func (*DB) Index

func (db *DB) Index() IndexDB

type EventMetadata

type EventMetadata struct {
	LocalBlock     uint64    `json:"localBlock,omitempty" form:"localBlock" query:"localBlock" validate:"required"`
	LocalTime      time.Time `json:"localTime,omitempty" form:"localTime" query:"localTime" validate:"required"`
	DirectoryBlock uint64    `json:"directoryBlock,omitempty" form:"directoryBlock" query:"directoryBlock" validate:"required"`
	DirectoryTime  time.Time `json:"directoryTime,omitempty" form:"directoryTime" query:"directoryTime" validate:"required"`
	// contains filtered or unexported fields
}

func (*EventMetadata) Copy

func (v *EventMetadata) Copy() *EventMetadata

func (*EventMetadata) CopyAsInterface

func (v *EventMetadata) CopyAsInterface() interface{}

func (*EventMetadata) Equal

func (v *EventMetadata) Equal(u *EventMetadata) bool

func (*EventMetadata) IsValid

func (v *EventMetadata) IsValid() error

func (*EventMetadata) MarshalBinary

func (v *EventMetadata) MarshalBinary() ([]byte, error)

func (*EventMetadata) MarshalJSON

func (v *EventMetadata) MarshalJSON() ([]byte, error)

func (*EventMetadata) UnmarshalBinary

func (v *EventMetadata) UnmarshalBinary(data []byte) error

func (*EventMetadata) UnmarshalBinaryFrom

func (v *EventMetadata) UnmarshalBinaryFrom(rd io.Reader) error

func (*EventMetadata) UnmarshalJSON

func (v *EventMetadata) UnmarshalJSON(b []byte) error

type IndexDB

type IndexDB interface {
	record.Record
	Account(url *url.URL) IndexDBAccount
	Partition(url *url.URL) IndexDBPartition
	Transaction(hash [32]byte) IndexDBTransaction
}

type IndexDBAccount

type IndexDBAccount interface {
	record.Record
	DidIndexTransactionExecution() values.Set[[32]byte]
	DidLoadTransaction() values.Set[[32]byte]
	Chain(name string) IndexDBAccountChain
}

type IndexDBAccountChain

type IndexDBAccountChain interface {
	record.Record
	Index() values.List[*protocol.IndexEntry]
}

type IndexDBPartition

type IndexDBPartition interface {
	record.Record
	Anchors() values.List[*AnchorMetadata]
}

type IndexDBTransaction

type IndexDBTransaction interface {
	record.Record
	Executed() values.Value[*EventMetadata]
}

Jump to

Keyboard shortcuts

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