indexer

package
v0.0.0-...-15eb78e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {

	// DBPath holds the db file path
	DBPath string
	// contains filtered or unexported fields
}

DB is a the db access layer for Indexer

func MakeIndexerDB

func MakeIndexerDB(dbPath string, inMemory bool) (*DB, error)

MakeIndexerDB takes the db path, a bool for inMemory and returns the IndexerDB control obj

func (*DB) AddBlock

func (idb *DB) AddBlock(b bookkeeping.Block) error

AddBlock takes an Algorand block and stores its transactions in the DB.

func (*DB) Close

func (idb *DB) Close()

Close closes the db connections

func (*DB) GetTransactionByID

func (idb *DB) GetTransactionByID(txid string) (Transaction, error)

GetTransactionByID takes a transaction ID and returns its transaction record

func (*DB) GetTransactionsRoundsByAddr

func (idb *DB) GetTransactionsRoundsByAddr(addr string, top uint64) ([]uint64, error)

GetTransactionsRoundsByAddr takes an address and returns all its transaction rounds records if top is 0, it will return 25 transactions by default

func (*DB) GetTransactionsRoundsByAddrAndDate

func (idb *DB) GetTransactionsRoundsByAddrAndDate(addr string, top uint64, from, to int64) ([]uint64, error)

GetTransactionsRoundsByAddrAndDate takes an address and a date range (as seconds from epoch) and returns all of its transaction rounds records. if top is 0, it will return 100 transactions by default

func (*DB) MaxRound

func (idb *DB) MaxRound() (uint64, error)

MaxRound returns the latest block in the DB

type Indexer

type Indexer struct {
	IDB *DB
	// contains filtered or unexported fields
}

Indexer keeps track of transactions and their senders to enable quick retrieval.

func MakeIndexer

func MakeIndexer(dataDir string, ledger Ledger, inMemory bool) (*Indexer, error)

MakeIndexer makes a new indexer.

func (*Indexer) GetRoundByTXID

func (idx *Indexer) GetRoundByTXID(txID string) (uint64, error)

GetRoundByTXID takes a transactionID an returns its round number

func (*Indexer) GetRoundsByAddress

func (idx *Indexer) GetRoundsByAddress(addr string, top uint64) ([]uint64, error)

GetRoundsByAddress takes an address and the number of transactions to return and returns all blocks that contain transaction where the address was the sender or the receiver.

func (*Indexer) GetRoundsByAddressAndDate

func (idx *Indexer) GetRoundsByAddressAndDate(addr string, top uint64, from, to int64) ([]uint64, error)

GetRoundsByAddressAndDate takes an address, date range and maximum number of txns to return , and returns all blocks that contain the relevant transaction. if top is 0, it defaults to 100.

func (*Indexer) LastBlock

func (idx *Indexer) LastBlock() (basics.Round, error)

LastBlock returns the last block the indexer is aware of

func (*Indexer) NewBlock

func (idx *Indexer) NewBlock(b bookkeeping.Block) error

NewBlock takes a block and updates the DB If the block exists, return nil.the block must be the next block

func (*Indexer) Shutdown

func (idx *Indexer) Shutdown()

Shutdown closes the indexer

func (*Indexer) Start

func (idx *Indexer) Start() error

Start starts the indexer

type Ledger

type Ledger interface {
	Block(rnd basics.Round) (blk bookkeeping.Block, err error)
	Wait(r basics.Round) chan struct{}
}

Ledger interface to make testing easier

type Transaction

type Transaction struct {
	TXID      string
	From      string `db:"from_addr_r"`
	To        string `db:"to_addr_r"`
	Round     uint32
	CreatedAt uint32 `db:"created_at"`
}

Transaction represents a transaction in the system

Jump to

Keyboard shortcuts

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