indexing

package
v0.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReachedChainEnd = errors.New("reached the end of the chain")
View Source
var ErrReachedChainStart = errors.New("reached the start of the chain")

Functions

func ReceiptForAccountState added in v0.6.0

func ReceiptForAccountState(net *config.Network, batch *Batch, account *Account) (block uint64, receipt *managed.Receipt, err error)

func ReceiptForChainEntry added in v0.6.0

func ReceiptForChainEntry(net *config.Network, batch *Batch, account *Account, hash []byte, entry *TransactionChainEntry) (uint64, *managed.Receipt, error)

func ReceiptForChainIndex added in v0.6.0

func ReceiptForChainIndex(net *config.Network, batch *Batch, account *Account, name string, index int64) (uint64, *managed.Receipt, error)

func SearchIndexChain added in v0.5.1

func SearchIndexChain(chain *database.Chain, index uint64, mode MatchMode, find IndexChainSearchFunction) (uint64, *protocol.IndexEntry, error)

SearchIndexChain searches along an index chain using the given search function. The search starts from the given index and proceeds forwards or backwards along the chain depending on the result of the search function.

Types

type BlockChainUpdatesIndex added in v0.6.0

type BlockChainUpdatesIndex struct {
	Entries []*ChainUpdate `json:"entries,omitempty" form:"entries" query:"entries" validate:"required"`
	// contains filtered or unexported fields
}

func (*BlockChainUpdatesIndex) Copy added in v0.6.0

func (*BlockChainUpdatesIndex) CopyAsInterface added in v0.6.0

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

func (*BlockChainUpdatesIndex) Equal added in v0.6.0

func (*BlockChainUpdatesIndex) IsValid added in v0.6.0

func (v *BlockChainUpdatesIndex) IsValid() error

func (*BlockChainUpdatesIndex) MarshalBinary added in v0.6.0

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

func (*BlockChainUpdatesIndex) MarshalJSON added in v0.6.0

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

func (*BlockChainUpdatesIndex) UnmarshalBinary added in v0.6.0

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

func (*BlockChainUpdatesIndex) UnmarshalBinaryFrom added in v0.6.0

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

func (*BlockChainUpdatesIndex) UnmarshalJSON added in v0.6.0

func (v *BlockChainUpdatesIndex) UnmarshalJSON(data []byte) error

type BlockChainUpdatesIndexer added in v0.6.0

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

BlockChainUpdatesIndexer indexes chain updates for each block.

func BlockChainUpdates added in v0.6.0

func BlockChainUpdates(batch *database.Batch, network *config.Network, blockIndex uint64) *BlockChainUpdatesIndexer

BlockChainUpdates returns a block updates indexer.

func (*BlockChainUpdatesIndexer) Get added in v0.6.0

Get loads and unmarshals the index. Get returns an empty index if it has not been defined.

func (*BlockChainUpdatesIndexer) Set added in v0.6.0

func (bu *BlockChainUpdatesIndexer) Set(updates []ChainUpdate) error

Set adds the updates array to the index.

type BlockStateIndex

type BlockStateIndex struct {
	ProducedSynthTxns []*BlockStateSynthTxnEntry `json:"producedSynthTxns,omitempty" form:"producedSynthTxns" query:"producedSynthTxns" validate:"required"`
	// contains filtered or unexported fields
}

func (*BlockStateIndex) Copy added in v0.5.1

func (v *BlockStateIndex) Copy() *BlockStateIndex

func (*BlockStateIndex) CopyAsInterface added in v0.5.1

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

func (*BlockStateIndex) Equal

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

func (*BlockStateIndex) IsValid

func (v *BlockStateIndex) IsValid() error

func (*BlockStateIndex) MarshalBinary

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

func (*BlockStateIndex) MarshalJSON added in v0.6.0

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

func (*BlockStateIndex) UnmarshalBinary

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

func (*BlockStateIndex) UnmarshalBinaryFrom

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

func (*BlockStateIndex) UnmarshalJSON added in v0.6.0

func (v *BlockStateIndex) UnmarshalJSON(data []byte) error

type BlockStateIndexer

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

BlockStateIndexer tracks transient state for a block.

func BlockState

func BlockState(batch *database.Batch, ledger *url.URL) *BlockStateIndexer

BlockState returns a block state indexer.

func (*BlockStateIndexer) Clear

func (x *BlockStateIndexer) Clear() error

Clear resets the block state.

func (*BlockStateIndexer) DidProduceSynthTxn

func (x *BlockStateIndexer) DidProduceSynthTxn(entry *BlockStateSynthTxnEntry) error

DidProduceSynthTxn records a produced synthetic transaction.

func (*BlockStateIndexer) Get

Get loads the block state.

type BlockStateSynthTxnEntry

type BlockStateSynthTxnEntry struct {
	Transaction []byte `json:"transaction,omitempty" form:"transaction" query:"transaction" validate:"required"`
	ChainEntry  uint64 `json:"chainEntry,omitempty" form:"chainEntry" query:"chainEntry" validate:"required"`
	// contains filtered or unexported fields
}

func (*BlockStateSynthTxnEntry) Copy added in v0.5.1

func (*BlockStateSynthTxnEntry) CopyAsInterface added in v0.5.1

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

func (*BlockStateSynthTxnEntry) Equal

func (*BlockStateSynthTxnEntry) IsValid

func (v *BlockStateSynthTxnEntry) IsValid() error

func (*BlockStateSynthTxnEntry) MarshalBinary

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

func (*BlockStateSynthTxnEntry) MarshalJSON

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

func (*BlockStateSynthTxnEntry) UnmarshalBinary

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

func (*BlockStateSynthTxnEntry) UnmarshalBinaryFrom

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

func (*BlockStateSynthTxnEntry) UnmarshalJSON

func (v *BlockStateSynthTxnEntry) UnmarshalJSON(data []byte) error

type ChainUpdate added in v0.6.0

type ChainUpdate struct {
	Account     *url.URL           `json:"account,omitempty" form:"account" query:"account" validate:"required"`
	Name        string             `json:"name,omitempty" form:"name" query:"name" validate:"required"`
	Type        protocol.ChainType `json:"type,omitempty" form:"type" query:"type" validate:"required"`
	Index       uint64             `json:"index,omitempty" form:"index" query:"index" validate:"required"`
	SourceIndex uint64             `json:"sourceIndex,omitempty" form:"sourceIndex" query:"sourceIndex" validate:"required"`
	SourceBlock uint64             `json:"sourceBlock,omitempty" form:"sourceBlock" query:"sourceBlock" validate:"required"`
	Entry       []byte             `json:"entry,omitempty" form:"entry" query:"entry" validate:"required"`
	// contains filtered or unexported fields
}

func (*ChainUpdate) Copy added in v0.6.0

func (v *ChainUpdate) Copy() *ChainUpdate

func (*ChainUpdate) CopyAsInterface added in v0.6.0

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

func (*ChainUpdate) Equal added in v0.6.0

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

func (*ChainUpdate) IsValid added in v0.6.0

func (v *ChainUpdate) IsValid() error

func (*ChainUpdate) MarshalBinary added in v0.6.0

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

func (*ChainUpdate) MarshalJSON added in v0.6.0

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

func (*ChainUpdate) UnmarshalBinary added in v0.6.0

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

func (*ChainUpdate) UnmarshalBinaryFrom added in v0.6.0

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

func (*ChainUpdate) UnmarshalJSON added in v0.6.0

func (v *ChainUpdate) UnmarshalJSON(data []byte) error

type DirectoryIndex added in v0.6.0

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

func Directory added in v0.6.0

func Directory(batch *database.Batch, account *url.URL) *DirectoryIndex

func (*DirectoryIndex) Count added in v0.6.0

func (d *DirectoryIndex) Count() (uint64, error)

func (*DirectoryIndex) Get added in v0.6.0

func (d *DirectoryIndex) Get(i uint64) (*url.URL, error)

func (*DirectoryIndex) Put added in v0.6.0

func (d *DirectoryIndex) Put(u *url.URL) error

type IndexChainSearchFunction added in v0.5.1

type IndexChainSearchFunction func(*protocol.IndexEntry) SearchDirection

IndexChainSearchFunction determines the direction an index chain search should proceed.

func SearchIndexChainByAnchorBounds added in v0.5.1

func SearchIndexChainByAnchorBounds(lowerBound, upperBound uint64) IndexChainSearchFunction

SearchIndexChainByAnchorBounds returns a search function that searches an index chain for an entry with an anchor in the given bounds (inclusive).

func SearchIndexChainByBlock added in v0.5.1

func SearchIndexChainByBlock(blockIndex uint64) IndexChainSearchFunction

SearchIndexChainByBlock returns a search function that searches an index chain for the given block index.

func SearchIndexChainBySource added in v0.5.1

func SearchIndexChainBySource(targetSource uint64) IndexChainSearchFunction

SearchIndexChainBySource returns a search function that searches an index chain for the given source.

type MatchMode added in v0.5.1

type MatchMode int

MatchMode determines how results are returned from a search.

const (
	// MatchExect returns only an exact match.
	MatchExact MatchMode = iota

	// MatchBefore returns the element before the target if the target cannot be
	// found.
	MatchBefore

	// MatchAfter returns the element after the target if the target cannot be
	// found.
	MatchAfter
)

type PendingTransactionsIndex

type PendingTransactionsIndex struct {
	Transactions [][32]byte `json:"transactions,omitempty" form:"transactions" query:"transactions" validate:"required"`
	// contains filtered or unexported fields
}

func (*PendingTransactionsIndex) Copy added in v0.5.1

func (*PendingTransactionsIndex) CopyAsInterface added in v0.5.1

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

func (*PendingTransactionsIndex) Equal

func (*PendingTransactionsIndex) IsValid

func (v *PendingTransactionsIndex) IsValid() error

func (*PendingTransactionsIndex) MarshalBinary

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

func (*PendingTransactionsIndex) MarshalJSON

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

func (*PendingTransactionsIndex) UnmarshalBinary

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

func (*PendingTransactionsIndex) UnmarshalBinaryFrom

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

func (*PendingTransactionsIndex) UnmarshalJSON

func (v *PendingTransactionsIndex) UnmarshalJSON(data []byte) error

type PendingTransactionsIndexer

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

PendingTransactionsIndexer indexes pending transactions of an account.

func PendingTransactions

func PendingTransactions(batch *database.Batch, account *url.URL) *PendingTransactionsIndexer

PendingTransactions returns a pending transactions indexer.

func (*PendingTransactionsIndexer) Add

func (x *PendingTransactionsIndexer) Add(txid [32]byte) error

Add adds a transaction to the list of pending transactions, if it is not already on the list.

func (*PendingTransactionsIndexer) Get

func (x *PendingTransactionsIndexer) Get() ([][32]byte, error)

Get loads the list of pending transactions.

func (*PendingTransactionsIndexer) Remove

func (x *PendingTransactionsIndexer) Remove(txid [32]byte) error

Remove removes a transaction from the list of pending transactions, if it is on the list.

type SearchDirection added in v0.5.1

type SearchDirection int

SearchDirection represents a direction to search along a linear index.

const (
	// SearchComplete is returned when the search is complete.
	SearchComplete SearchDirection = iota

	// SearchForward is returned when the search should proceed forwards along
	// the index.
	SearchForward

	// SearchBackward is returned when the search should proceed backwards along
	// the index.
	SearchBackward
)

type TransactionChainEntry

type TransactionChainEntry struct {
	Account *url.URL `json:"account,omitempty" form:"account" query:"account" validate:"required"`
	// Chain is the name of the chain.
	Chain string `json:"chain,omitempty" form:"chain" query:"chain" validate:"required"`
	// ChainIndex is the index of the entry in the chain's index chain.
	ChainIndex uint64 `json:"chainIndex,omitempty" form:"chainIndex" query:"chainIndex" validate:"required"`
	// AnchorIndex is the index of the entry in the anchor chain's index chain.
	AnchorIndex uint64 `json:"anchorIndex,omitempty" form:"anchorIndex" query:"anchorIndex" validate:"required"`
	// contains filtered or unexported fields
}

func (*TransactionChainEntry) Copy added in v0.5.1

func (*TransactionChainEntry) CopyAsInterface added in v0.5.1

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

func (*TransactionChainEntry) Equal

func (*TransactionChainEntry) IsValid

func (v *TransactionChainEntry) IsValid() error

func (*TransactionChainEntry) MarshalBinary

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

func (*TransactionChainEntry) UnmarshalBinary

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

func (*TransactionChainEntry) UnmarshalBinaryFrom

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

type TransactionChainIndex

type TransactionChainIndex struct {
	Entries []*TransactionChainEntry `json:"entries,omitempty" form:"entries" query:"entries" validate:"required"`
	// contains filtered or unexported fields
}

func (*TransactionChainIndex) Copy added in v0.5.1

func (*TransactionChainIndex) CopyAsInterface added in v0.5.1

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

func (*TransactionChainIndex) Equal

func (*TransactionChainIndex) IsValid

func (v *TransactionChainIndex) IsValid() error

func (*TransactionChainIndex) MarshalBinary

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

func (*TransactionChainIndex) MarshalJSON added in v0.6.0

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

func (*TransactionChainIndex) UnmarshalBinary

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

func (*TransactionChainIndex) UnmarshalBinaryFrom

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

func (*TransactionChainIndex) UnmarshalJSON added in v0.6.0

func (v *TransactionChainIndex) UnmarshalJSON(data []byte) error

type TransactionChainIndexer

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

TransactionChainIndexer indexes account chains against a transaction.

func TransactionChain

func TransactionChain(batch *database.Batch, txid []byte) *TransactionChainIndexer

TransactionChain returns a transaction chain indexer.

func (*TransactionChainIndexer) Add

Add adds a new entry to the index.

func (*TransactionChainIndexer) Get

Get loads and unmarshals the index. Get returns an empty index if it has not been defined.

Jump to

Keyboard shortcuts

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