indexing

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReachedChainEnd = errors.New(errors.StatusNotFound, "reached the end of the chain")
View Source
var ErrReachedChainStart = errors.New(errors.StatusNotFound, "reached the start of the chain")
View Source
var ErrTargetDoesNotExist = errors.New(errors.StatusNotFound, "target does not exist")

Functions

func GetDataEntry added in v1.0.0

func GetDataEntry(batch *database.Batch, txnHash []byte) (protocol.DataEntry, *url.TxID, *url.TxID, error)

func LoadIndexEntryFromEnd added in v0.6.0

func LoadIndexEntryFromEnd(c *database.Chain2, offset uint64) (*protocol.IndexEntry, error)

LoadIndexEntryFromEnd loads the Nth-to-last entry from an index chain. LoadIndexEntryFromEnd will panic if the offset is zero. If the offset is greater than the chain height, LoadIndexEntryFromEnd returns nil, nil.

func LoadLastTwoIndexEntries added in v0.6.0

func LoadLastTwoIndexEntries(chain *database.Chain2) (last, nextLast *protocol.IndexEntry, err error)

LoadLastTwoIndexEntries loads the last and next to last entries of the index chain.

func ReceiptForAccountState added in v0.6.0

func ReceiptForAccountState(net *config.Describe, batch *database.Batch, account *database.Account) (block *protocol.IndexEntry, receipt *managed.Receipt, err error)

func ReceiptForChainEntry added in v0.6.0

func ReceiptForChainEntry(net *config.Describe, batch *database.Batch, account *database.Account, hash []byte, entry *database.TransactionChainEntry) (*protocol.IndexEntry, *managed.Receipt, error)

func ReceiptForChainIndex added in v0.6.0

func ReceiptForChainIndex(net *config.Describe, batch *database.Batch, c *database.Chain2, index int64) (*protocol.IndexEntry, *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 DataIndexer added in v1.0.0

type DataIndexer struct {
	*database.AccountData
	// contains filtered or unexported fields
}

func Data added in v1.0.0

func Data(batch *database.Batch, account *url.URL) *DataIndexer

func (*DataIndexer) Count added in v1.0.0

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

func (*DataIndexer) Entry added in v1.0.0

func (d *DataIndexer) Entry(i uint64) ([]byte, error)

Entry returns the entry hash for the given index.

func (*DataIndexer) GetLatest added in v1.0.0

func (d *DataIndexer) GetLatest() (index uint64, entryHash, txnHash []byte, err error)

GetLatest returns the last entry.

func (*DataIndexer) GetLatestEntry added in v1.0.0

func (d *DataIndexer) GetLatestEntry() (protocol.DataEntry, *url.TxID, *url.TxID, error)

func (*DataIndexer) Put added in v1.0.0

func (d *DataIndexer) Put(entryHash, txnHash []byte) error

func (*DataIndexer) Transaction added in v1.0.0

func (d *DataIndexer) Transaction(entryHash []byte) ([]byte, error)

Transaction returns the transaction hash for the given entry hash.

type DirectoryIndexer added in v1.0.0

type DirectoryIndexer struct {
	*record.Set[*url.URL]
}

func Directory added in v0.6.0

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

func (*DirectoryIndexer) Count added in v1.0.0

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

func (*DirectoryIndexer) Get added in v1.0.0

func (d *DirectoryIndexer) Get(i uint64) (*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 SearchIndexChainByRootIndexIndex added in v1.0.0

func SearchIndexChainByRootIndexIndex(targetRootIndexIndex uint64) IndexChainSearchFunction

SearchIndexChainByRootIndexIndex returns a search function that searches an index chain for the given RootIndexIndex.

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 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 TransactionChainIndexer

type TransactionChainIndexer struct {
	*record.Set[*database.TransactionChainEntry]
}

TransactionChainIndexer indexes account chains against a transaction.

func TransactionChain

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

TransactionChain returns a transaction chain indexer.

Jump to

Keyboard shortcuts

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