Documentation
¶
Overview ¶
Package light implements an Accumulate light client.
THIS PACKAGE IS EXPERIMENTAL AND SUBJECT TO CHANGE. ¶
Index ¶
- func ByAnchorBlock(block uint64) func(*AnchorMetadata) bool
- func ByIndexBlock(block uint64) func(*protocol.IndexEntry) bool
- func ByIndexRootIndexIndex(rootIndex uint64) func(*protocol.IndexEntry) bool
- func ByIndexSource(source uint64) func(*protocol.IndexEntry) bool
- func ByIndexTime(t time.Time) func(*protocol.IndexEntry) bool
- func FindEntry[T any](entries []T, fn func(T) bool) (int, T, bool)
- type AnchorMetadata
- func (v *AnchorMetadata) Copy() *AnchorMetadata
- func (v *AnchorMetadata) CopyAsInterface() interface{}
- func (v *AnchorMetadata) Equal(u *AnchorMetadata) bool
- func (v *AnchorMetadata) IsValid() error
- func (v *AnchorMetadata) MarshalBinary() ([]byte, error)
- func (v *AnchorMetadata) MarshalJSON() ([]byte, error)
- func (v *AnchorMetadata) UnmarshalBinary(data []byte) error
- func (v *AnchorMetadata) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *AnchorMetadata) UnmarshalJSON(b []byte) error
- type ChainIndex
- func (c *ChainIndex[T]) Append(key T, index uint64) error
- func (c *ChainIndex[T]) Chain() *database.Chain2
- func (c *ChainIndex[T]) Find(key T) merkle.ChainSearchResult
- func (c *ChainIndex[T]) FindExactIndexEntry(key T) (*protocol.IndexEntry, error)
- func (c *ChainIndex[T]) FindIndexEntryAfter(key T) (*protocol.IndexEntry, error)
- func (c *ChainIndex[T]) FindIndexEntryBefore(key T) (*protocol.IndexEntry, error)
- type ChainIndexTime
- type ChainIndexUint
- type Client
- func (c *Client) Close() error
- func (c *Client) GetBlockForTime(account *url.URL, time time.Time) (uint64, error)
- func (c *Client) IndexAccountChains(ctx context.Context, acctUrl *url.URL) error
- func (c *Client) IndexAccountTransactions(ctx context.Context, accounts ...*url.URL) error
- func (c *Client) IndexProducedAnchors(ctx context.Context, partUrl *url.URL) error
- func (c *Client) IndexReceivedAnchors(ctx context.Context, partUrl *url.URL) error
- func (c *Client) OpenDB(writable bool) *DB
- func (c *Client) PullAccount(ctx context.Context, acctUrl *url.URL) error
- func (c *Client) PullAccountWithChains(ctx context.Context, acctUrl *url.URL, predicate func(*api.ChainRecord) bool) error
- func (c *Client) PullMessagesForAccount(ctx context.Context, account *url.URL, chains ...string) error
- func (c *Client) PullMessagesForAccountSince(ctx context.Context, account *url.URL, since time.Time, chains ...string) error
- func (c *Client) PullPendingTransactionsForAccount(ctx context.Context, account *url.URL) error
- func (c *Client) PullTransactions(ctx context.Context, txids ...*url.TxID) error
- func (c *Client) PullTransactionsForAccount(ctx context.Context, account *url.URL, chains ...string) error
- type ClientOption
- func BadgerStore(filepath string, opts ...badger.Option) ClientOption
- func ClientV2(client *client.Client) ClientOption
- func Logger(logger log.Logger, keyVals ...any) ClientOptiondeprecated
- func MemoryStore() ClientOption
- func Querier(querier api.Querier) ClientOption
- func Router(r routing.Router) ClientOption
- func RouterFromStore() ClientOption
- func Server(server string) ClientOption
- func Store(s keyvalue.Beginner, prefix string) ClientOption
- type DB
- type EventMetadata
- func (v *EventMetadata) Copy() *EventMetadata
- func (v *EventMetadata) CopyAsInterface() interface{}
- func (v *EventMetadata) Equal(u *EventMetadata) bool
- func (v *EventMetadata) IsValid() error
- func (v *EventMetadata) MarshalBinary() ([]byte, error)
- func (v *EventMetadata) MarshalJSON() ([]byte, error)
- func (v *EventMetadata) UnmarshalBinary(data []byte) error
- func (v *EventMetadata) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *EventMetadata) UnmarshalJSON(b []byte) error
- type IndexDB
- func (c *IndexDB) Account(url *url.URL) *IndexDBAccount
- func (c *IndexDB) Commit() error
- func (c *IndexDB) IsDirty() bool
- func (c *IndexDB) Key() *record.Key
- func (c *IndexDB) Partition(url *url.URL) *IndexDBPartition
- func (c *IndexDB) Resolve(key *record.Key) (record.Record, *record.Key, error)
- func (c *IndexDB) Transaction(hash [32]byte) *IndexDBTransaction
- func (c *IndexDB) Walk(opts record.WalkOptions, fn record.WalkFunc) error
- type IndexDBAccount
- func (c *IndexDBAccount) Chain(name string) *IndexDBAccountChain
- func (c *IndexDBAccount) Commit() error
- func (c *IndexDBAccount) DidIndexTransactionExecution() values.Set[[32]byte]
- func (c *IndexDBAccount) IsDirty() bool
- func (c *IndexDBAccount) Key() *record.Key
- func (c *IndexDBAccount) Resolve(key *record.Key) (record.Record, *record.Key, error)
- func (c *IndexDBAccount) Walk(opts record.WalkOptions, fn record.WalkFunc) error
- type IndexDBAccountChain
- func (c *IndexDBAccountChain) BlockIndex() *ChainIndexUint
- func (c *IndexDBAccountChain) BlockTime() *ChainIndexTime
- func (c *IndexDBAccountChain) Commit() error
- func (i *IndexDBAccountChain) DidLoad() RangeSet
- func (c *IndexDBAccountChain) IsDirty() bool
- func (c *IndexDBAccountChain) Key() *record.Key
- func (c *IndexDBAccountChain) Resolve(key *record.Key) (record.Record, *record.Key, error)
- func (c *IndexDBAccountChain) RootIndexIndex() *ChainIndexUint
- func (c *IndexDBAccountChain) SourceIndex() *ChainIndexUint
- func (c *IndexDBAccountChain) Walk(opts record.WalkOptions, fn record.WalkFunc) error
- type IndexDBPartition
- func (c *IndexDBPartition) Anchors() *IndexDBPartitionAnchors
- func (c *IndexDBPartition) Commit() error
- func (c *IndexDBPartition) IsDirty() bool
- func (c *IndexDBPartition) Key() *record.Key
- func (c *IndexDBPartition) Resolve(key *record.Key) (record.Record, *record.Key, error)
- func (c *IndexDBPartition) Walk(opts record.WalkOptions, fn record.WalkFunc) error
- type IndexDBPartitionAnchors
- func (c *IndexDBPartitionAnchors) Commit() error
- func (c *IndexDBPartitionAnchors) IsDirty() bool
- func (c *IndexDBPartitionAnchors) Key() *record.Key
- func (c *IndexDBPartitionAnchors) Produced() *IndexedList[*AnchorMetadata]
- func (c *IndexDBPartitionAnchors) Received(url *url.URL) *ChainIndexUint
- func (c *IndexDBPartitionAnchors) Resolve(key *record.Key) (record.Record, *record.Key, error)
- func (c *IndexDBPartitionAnchors) Walk(opts record.WalkOptions, fn record.WalkFunc) error
- type IndexDBTransaction
- func (c *IndexDBTransaction) Commit() error
- func (c *IndexDBTransaction) Executed() values.Value[*EventMetadata]
- func (c *IndexDBTransaction) IsDirty() bool
- func (c *IndexDBTransaction) Key() *record.Key
- func (c *IndexDBTransaction) Resolve(key *record.Key) (record.Record, *record.Key, error)
- func (c *IndexDBTransaction) Walk(opts record.WalkOptions, fn record.WalkFunc) error
- type IndexedList
- type RangeSet
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 ByIndexTime ¶ added in v1.4.0
func ByIndexTime(t time.Time) func(*protocol.IndexEntry) bool
ByIndexTime searches for an index entry with protocol.IndexEntry.BlockTime equal to or greater than the given value.
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"` Transaction *protocol.Transaction `json:"transaction,omitempty" form:"transaction" query:"transaction" 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 ChainIndex ¶ added in v1.4.0
type ChainIndex[T any] struct { *merkle.ChainIndex // contains filtered or unexported fields }
func (*ChainIndex[T]) Append ¶ added in v1.4.0
func (c *ChainIndex[T]) Append(key T, index uint64) error
func (*ChainIndex[T]) Chain ¶ added in v1.4.0
func (c *ChainIndex[T]) Chain() *database.Chain2
func (*ChainIndex[T]) Find ¶ added in v1.4.0
func (c *ChainIndex[T]) Find(key T) merkle.ChainSearchResult
func (*ChainIndex[T]) FindExactIndexEntry ¶ added in v1.4.0
func (c *ChainIndex[T]) FindExactIndexEntry(key T) (*protocol.IndexEntry, error)
func (*ChainIndex[T]) FindIndexEntryAfter ¶ added in v1.4.0
func (c *ChainIndex[T]) FindIndexEntryAfter(key T) (*protocol.IndexEntry, error)
func (*ChainIndex[T]) FindIndexEntryBefore ¶ added in v1.4.0
func (c *ChainIndex[T]) FindIndexEntryBefore(key T) (*protocol.IndexEntry, error)
type ChainIndexTime ¶ added in v1.4.0
type ChainIndexTime = ChainIndex[time.Time]
type ChainIndexUint ¶ added in v1.4.0
type ChainIndexUint = ChainIndex[uint64]
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) GetBlockForTime ¶ added in v1.4.0
func (*Client) IndexAccountChains ¶
IndexAccountChains collates the index chain entries for an account's chains.
func (*Client) IndexAccountTransactions ¶
IndexAccountTransaction indexes the local and directory block index and time for the accounts' main chain transactions.
func (*Client) IndexProducedAnchors ¶ added in v1.4.0
IndexProducedAnchors collates a partition's produced block anchors.
func (*Client) IndexReceivedAnchors ¶ added in v1.4.0
IndexReceivedAnchors collates a partition's received block anchors.
func (*Client) PullAccount ¶
PullAccount fetches the latest version of the account and its chains.
func (*Client) PullAccountWithChains ¶ added in v1.4.0
func (*Client) PullMessagesForAccount ¶ added in v1.2.0
func (*Client) PullMessagesForAccountSince ¶ added in v1.4.0
func (*Client) PullPendingTransactionsForAccount ¶
func (*Client) PullTransactions ¶
PullTransaction fetches a set of transactions.
type ClientOption ¶
func BadgerStore ¶
func BadgerStore(filepath string, opts ...badger.Option) ClientOption
func ClientV2 ¶
func ClientV2(client *client.Client) ClientOption
func Logger
deprecated
func Logger(logger log.Logger, keyVals ...any) ClientOption
Logger sets the logger.
Deprecated: Unused - using slog instead.
func MemoryStore ¶
func MemoryStore() ClientOption
func Querier ¶ added in v1.2.0
func Querier(querier api.Querier) ClientOption
func Router ¶ added in v1.4.0
func Router(r routing.Router) ClientOption
func RouterFromStore ¶ added in v1.4.0
func RouterFromStore() ClientOption
func Server ¶
func Server(server string) ClientOption
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 struct {
// contains filtered or unexported fields
}
func (*IndexDB) Transaction ¶
func (c *IndexDB) Transaction(hash [32]byte) *IndexDBTransaction
type IndexDBAccount ¶
type IndexDBAccount struct {
// contains filtered or unexported fields
}
func (*IndexDBAccount) Chain ¶
func (c *IndexDBAccount) Chain(name string) *IndexDBAccountChain
func (*IndexDBAccount) Commit ¶ added in v1.4.0
func (c *IndexDBAccount) Commit() error
func (*IndexDBAccount) DidIndexTransactionExecution ¶
func (c *IndexDBAccount) DidIndexTransactionExecution() values.Set[[32]byte]
func (*IndexDBAccount) IsDirty ¶ added in v1.4.0
func (c *IndexDBAccount) IsDirty() bool
func (*IndexDBAccount) Key ¶ added in v1.4.0
func (c *IndexDBAccount) Key() *record.Key
func (*IndexDBAccount) Walk ¶ added in v1.4.0
func (c *IndexDBAccount) Walk(opts record.WalkOptions, fn record.WalkFunc) error
type IndexDBAccountChain ¶
type IndexDBAccountChain struct {
// contains filtered or unexported fields
}
func (*IndexDBAccountChain) BlockIndex ¶ added in v1.4.0
func (c *IndexDBAccountChain) BlockIndex() *ChainIndexUint
func (*IndexDBAccountChain) BlockTime ¶ added in v1.4.0
func (c *IndexDBAccountChain) BlockTime() *ChainIndexTime
func (*IndexDBAccountChain) Commit ¶ added in v1.4.0
func (c *IndexDBAccountChain) Commit() error
func (*IndexDBAccountChain) DidLoad ¶ added in v1.4.0
func (i *IndexDBAccountChain) DidLoad() RangeSet
func (*IndexDBAccountChain) IsDirty ¶ added in v1.4.0
func (c *IndexDBAccountChain) IsDirty() bool
func (*IndexDBAccountChain) Key ¶ added in v1.4.0
func (c *IndexDBAccountChain) Key() *record.Key
func (*IndexDBAccountChain) RootIndexIndex ¶ added in v1.4.0
func (c *IndexDBAccountChain) RootIndexIndex() *ChainIndexUint
func (*IndexDBAccountChain) SourceIndex ¶ added in v1.4.0
func (c *IndexDBAccountChain) SourceIndex() *ChainIndexUint
func (*IndexDBAccountChain) Walk ¶ added in v1.4.0
func (c *IndexDBAccountChain) Walk(opts record.WalkOptions, fn record.WalkFunc) error
type IndexDBPartition ¶
type IndexDBPartition struct {
// contains filtered or unexported fields
}
func (*IndexDBPartition) Anchors ¶
func (c *IndexDBPartition) Anchors() *IndexDBPartitionAnchors
func (*IndexDBPartition) Commit ¶ added in v1.4.0
func (c *IndexDBPartition) Commit() error
func (*IndexDBPartition) IsDirty ¶ added in v1.4.0
func (c *IndexDBPartition) IsDirty() bool
func (*IndexDBPartition) Key ¶ added in v1.4.0
func (c *IndexDBPartition) Key() *record.Key
func (*IndexDBPartition) Walk ¶ added in v1.4.0
func (c *IndexDBPartition) Walk(opts record.WalkOptions, fn record.WalkFunc) error
type IndexDBPartitionAnchors ¶ added in v1.4.0
type IndexDBPartitionAnchors struct {
// contains filtered or unexported fields
}
func (*IndexDBPartitionAnchors) Commit ¶ added in v1.4.0
func (c *IndexDBPartitionAnchors) Commit() error
func (*IndexDBPartitionAnchors) IsDirty ¶ added in v1.4.0
func (c *IndexDBPartitionAnchors) IsDirty() bool
func (*IndexDBPartitionAnchors) Key ¶ added in v1.4.0
func (c *IndexDBPartitionAnchors) Key() *record.Key
func (*IndexDBPartitionAnchors) Produced ¶ added in v1.4.0
func (c *IndexDBPartitionAnchors) Produced() *IndexedList[*AnchorMetadata]
func (*IndexDBPartitionAnchors) Received ¶ added in v1.4.0
func (c *IndexDBPartitionAnchors) Received(url *url.URL) *ChainIndexUint
func (*IndexDBPartitionAnchors) Walk ¶ added in v1.4.0
func (c *IndexDBPartitionAnchors) Walk(opts record.WalkOptions, fn record.WalkFunc) error
type IndexDBTransaction ¶
type IndexDBTransaction struct {
// contains filtered or unexported fields
}
func (*IndexDBTransaction) Commit ¶ added in v1.4.0
func (c *IndexDBTransaction) Commit() error
func (*IndexDBTransaction) Executed ¶
func (c *IndexDBTransaction) Executed() values.Value[*EventMetadata]
func (*IndexDBTransaction) IsDirty ¶ added in v1.4.0
func (c *IndexDBTransaction) IsDirty() bool
func (*IndexDBTransaction) Key ¶ added in v1.4.0
func (c *IndexDBTransaction) Key() *record.Key
func (*IndexDBTransaction) Walk ¶ added in v1.4.0
func (c *IndexDBTransaction) Walk(opts record.WalkOptions, fn record.WalkFunc) error