indexing

package
v0.5.1-rc4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 11 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 SearchIndexChain added in v0.5.1

func SearchIndexChain(chain *database.Chain, index uint64, 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 BlockStateIndex

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

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) UnmarshalBinary

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

func (*BlockStateIndex) UnmarshalBinaryFrom

func (v *BlockStateIndex) UnmarshalBinaryFrom(rd io.Reader) 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) 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 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.

type PendingTransactionsIndex

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

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) 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) Equal

func (*TransactionChainIndex) IsValid

func (v *TransactionChainIndex) IsValid() error

func (*TransactionChainIndex) MarshalBinary

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

func (*TransactionChainIndex) UnmarshalBinary

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

func (*TransactionChainIndex) UnmarshalBinaryFrom

func (v *TransactionChainIndex) UnmarshalBinaryFrom(rd io.Reader) 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