explorer

package module
v0.0.0-...-9bc7f68 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 5 Imported by: 0

README

Sia Core

An explorer backend for Sia.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainStats

type ChainStats struct {
	Block types.Block

	// Transaction type counts.
	SpentSiacoinsCount uint64
	SpentSiafundsCount uint64

	// Facts about file contracts.
	ActiveContractCost  types.Currency
	ActiveContractCount uint64
	ActiveContractSize  uint64
	TotalContractCost   types.Currency
	TotalContractSize   uint64
	TotalRevisionVolume uint64
}

ChainStats contains a bunch of statistics about the consensus set as they were at a specific block.

func (*ChainStats) DecodeFrom

func (cs *ChainStats) DecodeFrom(d *types.Decoder)

DecodeFrom implements types.DecoderFrom.

func (ChainStats) EncodeTo

func (cs ChainStats) EncodeTo(e *types.Encoder)

EncodeTo implements types.EncoderTo.

type Explorer

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

An Explorer contains a database storing information about blocks, outputs, contracts.

func NewExplorer

func NewExplorer(cs consensus.State, store Store, hashStore HashStore) *Explorer

NewExplorer creates a new explorer.

func (*Explorer) ChainStats

func (e *Explorer) ChainStats(index types.ChainIndex) (ChainStats, error)

ChainStats returns stats about the black at the the specified height.

func (*Explorer) ChainStatsLatest

func (e *Explorer) ChainStatsLatest() (ChainStats, error)

ChainStatsLatest returns stats about the latest black.

func (*Explorer) FileContractElement

func (e *Explorer) FileContractElement(id types.ElementID) (types.FileContractElement, error)

FileContractElement returns the file contract element associated with the specified ID.

func (*Explorer) MerkleProof

func (e *Explorer) MerkleProof(id types.ElementID) ([]types.Hash256, error)

MerkleProof returns the current merkle proof for a given element.

func (*Explorer) ProcessChainApplyUpdate

func (e *Explorer) ProcessChainApplyUpdate(cau *chain.ApplyUpdate, mayCommit bool) error

ProcessChainApplyUpdate implements chain.Subscriber.

func (*Explorer) ProcessChainRevertUpdate

func (e *Explorer) ProcessChainRevertUpdate(cru *chain.RevertUpdate) error

ProcessChainRevertUpdate implements chain.Subscriber.

func (*Explorer) SiacoinBalance

func (e *Explorer) SiacoinBalance(address types.Address) (types.Currency, error)

SiacoinBalance returns the siacoin balance of an address.

func (*Explorer) SiacoinElement

func (e *Explorer) SiacoinElement(id types.ElementID) (types.SiacoinElement, error)

SiacoinElement returns the siacoin element associated with the specified ID.

func (*Explorer) SiafundBalance

func (e *Explorer) SiafundBalance(address types.Address) (uint64, error)

SiafundBalance returns the siafund balance of an address.

func (*Explorer) SiafundElement

func (e *Explorer) SiafundElement(id types.ElementID) (types.SiafundElement, error)

SiafundElement returns the siafund element associated with the specified ID.

func (*Explorer) Size

func (e *Explorer) Size() (uint64, error)

Size returns the combined size in bytes of the SQL store and the hash store.

func (*Explorer) State

func (e *Explorer) State(index types.ChainIndex) (consensus.State, error)

State returns the chain state for a given chain index.

func (*Explorer) Transaction

func (e *Explorer) Transaction(id types.TransactionID) (types.Transaction, error)

Transaction returns the transaction with the given ID.

func (*Explorer) Transactions

func (e *Explorer) Transactions(address types.Address, amount, offset int) ([]types.TransactionID, error)

Transactions returns the latest n transaction IDs associated with the specified address.

func (*Explorer) UnspentSiacoinElements

func (e *Explorer) UnspentSiacoinElements(address types.Address) ([]types.ElementID, error)

UnspentSiacoinElements returns unspent siacoin elements associated with the specified address.

func (*Explorer) UnspentSiafundElements

func (e *Explorer) UnspentSiafundElements(address types.Address) ([]types.ElementID, error)

UnspentSiafundElements returns unspent siafund elements associated with the specified address.

type HashStore

type HashStore interface {
	Size() (uint64, error)
	Commit() error
	ModifyLeaf(elem types.StateElement) error
	MerkleProof(leafIndex uint64) ([]types.Hash256, error)
}

A HashStore can read and write hashes for nodes in the log's tree structure.

type Store

type Store interface {
	ChainStats(index types.ChainIndex) (ChainStats, error)
	SiacoinElement(id types.ElementID) (types.SiacoinElement, error)
	SiafundElement(id types.ElementID) (types.SiafundElement, error)
	FileContractElement(id types.ElementID) (types.FileContractElement, error)
	UnspentSiacoinElements(address types.Address) ([]types.ElementID, error)
	UnspentSiafundElements(address types.Address) ([]types.ElementID, error)
	Transaction(id types.TransactionID) (types.Transaction, error)
	Transactions(address types.Address, amount, offset int) ([]types.TransactionID, error)
	State(index types.ChainIndex) (context consensus.State, err error)

	AddSiacoinElement(sce types.SiacoinElement)
	AddSiafundElement(sfe types.SiafundElement)
	AddFileContractElement(fce types.FileContractElement)
	RemoveElement(id types.ElementID)
	AddChainStats(index types.ChainIndex, stats ChainStats)
	AddUnspentSiacoinElement(address types.Address, id types.ElementID)
	AddUnspentSiafundElement(address types.Address, id types.ElementID)
	RemoveUnspentSiacoinElement(address types.Address, id types.ElementID)
	RemoveUnspentSiafundElement(address types.Address, id types.ElementID)
	AddTransaction(txn types.Transaction, addresses []types.Address, block types.ChainIndex)
	AddState(index types.ChainIndex, context consensus.State)

	Size() (uint64, error)
	Commit() error
}

A Store is a database that stores information about elements, contracts, and blocks.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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