explorer

package
v0.0.0-...-b118cd4 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoTip is returned when we are unable to find the tip in the
	// database or there is no tips at all.
	ErrNoTip = errors.New("no tip found")

	// ErrContractNotFound is returned when ContractRevisions is unable to find
	// the specified contract ID.
	ErrContractNotFound = errors.New("contract not found")

	// ErrSearchParse is returned when Search is unable to parse the specified
	// ID.
	ErrSearchParse = errors.New("error parsing ID")

	// ErrNoSearchResults is returned when Search is unable to find anything
	// with the specified ID.
	ErrNoSearchResults = errors.New("no search results")
)

Functions

func RelevantAddressesV1

func RelevantAddressesV1(txn types.Transaction) []types.Address

RelevantAddressesV1 returns all the relevant addresses to a V1 transaction.

func RelevantAddressesV2

func RelevantAddressesV2(txn types.V2Transaction) []types.Address

RelevantAddressesV2 returns all the relevant addresses to a V2 transaction.

func UpdateChainState

func UpdateChainState(tx UpdateTx, crus []chain.RevertUpdate, caus []chain.ApplyUpdate) error

UpdateChainState applies the reverts and updates.

Types

type Block

type Block struct {
	Height       uint64          `json:"height"`
	ParentID     types.BlockID   `json:"parentID"`
	Nonce        uint64          `json:"nonce"`
	Timestamp    time.Time       `json:"timestamp"`
	LeafIndex    uint64          `json:"leafIndex"`
	MinerPayouts []SiacoinOutput `json:"minerPayouts"`
	Transactions []Transaction   `json:"transactions"`

	V2 *V2BlockData `json:"v2,omitempty"`
}

A Block is a block containing wrapped transactions and siacoin outputs for the miner payouts.

type ChainManager

type ChainManager interface {
	PoolTransactions() []types.Transaction
	V2PoolTransactions() []types.V2Transaction

	Tip() types.ChainIndex
	TipState() consensus.State
	BestIndex(height uint64) (types.ChainIndex, bool)

	OnReorg(fn func(types.ChainIndex)) (cancel func())
	UpdatesSince(index types.ChainIndex, max int) (rus []chain.RevertUpdate, aus []chain.ApplyUpdate, err error)
}

A ChainManager manages the consensus state

type ChainUpdate

type ChainUpdate interface {
	SiacoinElementDiffs() []consensus.SiacoinElementDiff
	SiafundElementDiffs() []consensus.SiafundElementDiff
	FileContractElementDiffs() []consensus.FileContractElementDiff
	V2FileContractElementDiffs() []consensus.V2FileContractElementDiff
}

A ChainUpdate is a set of changes to the consensus state.

type ContractSiacoinOutput

type ContractSiacoinOutput struct {
	ID types.SiacoinOutputID `json:"id"`
	types.SiacoinOutput
}

A ContractSiacoinOutput is a SiacoinOutput with an added field for its ID.

type DBFileContract

type DBFileContract struct {
	ID             types.FileContractID
	RevisionNumber uint64
}

A DBFileContract represents a file contract element in the DB.

type Event

type Event struct {
	ID             types.Hash256    `json:"id"`
	Index          types.ChainIndex `json:"index"`
	Confirmations  uint64           `json:"confirmations"`
	Type           string           `json:"type"`
	Data           EventData        `json:"data"`
	MaturityHeight uint64           `json:"maturityHeight"`
	Timestamp      time.Time        `json:"timestamp"`
	Relevant       []types.Address  `json:"relevant,omitempty"`
}

An Event is a transaction or other event that affects the wallet including miner payouts, siafund claims, and file contract payouts.

func AppliedEvents

func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate) (events []Event)

AppliedEvents extracts a list of relevant events from a chain update.

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type EventData

type EventData interface {
	// contains filtered or unexported methods
}

EventData contains the data associated with an event.

type EventPayout

type EventPayout struct {
	SiacoinElement SiacoinOutput `json:"siacoinElement"`
}

An EventPayout represents a miner payout, siafund claim, or foundation subsidy.

type EventV1ContractResolution

type EventV1ContractResolution struct {
	Parent         ExtendedFileContract `json:"parent"`
	SiacoinElement SiacoinOutput        `json:"siacoinElement"`
	Missed         bool                 `json:"missed"`
}

An EventV1ContractResolution represents a file contract payout from a v1 contract.

type EventV1Transaction

type EventV1Transaction struct {
	Transaction Transaction `json:"transaction"`
}

An EventV1Transaction pairs a v1 transaction with its spent siacoin and siafund elements.

type EventV2ContractResolution

type EventV2ContractResolution struct {
	Resolution     V2FileContractResolution `json:"resolution"`
	SiacoinElement SiacoinOutput            `json:"siacoinElement"`
	Missed         bool                     `json:"missed"`
}

An EventV2ContractResolution represents a file contract payout from a v2 contract.

type EventV2Transaction

type EventV2Transaction V2Transaction

EventV2Transaction is a transaction event that includes the transaction

type Explorer

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

Explorer implements a Sia explorer.

func NewExplorer

func NewExplorer(cm ChainManager, store Store, batchSize int, scanCfg config.Scanner, log *zap.Logger) (*Explorer, error)

NewExplorer returns a Sia explorer.

func (*Explorer) AddressEvents

func (e *Explorer) AddressEvents(address types.Address, offset, limit uint64) (events []Event, err error)

AddressEvents returns the events of a single address.

func (*Explorer) AddressUnconfirmedEvents

func (e *Explorer) AddressUnconfirmedEvents(address types.Address) ([]Event, error)

AddressUnconfirmedEvents returns the unconfirmed events for a single address.

func (*Explorer) Balance

func (e *Explorer) Balance(address types.Address) (sc types.Currency, immatureSC types.Currency, sf uint64, err error)

Balance returns the balance of an address.

func (*Explorer) BestTip

func (e *Explorer) BestTip(height uint64) (types.ChainIndex, error)

BestTip returns the chain index at the specified height.

func (*Explorer) Block

func (e *Explorer) Block(id types.BlockID) (Block, error)

Block returns the block with the specified ID.

func (*Explorer) ContractRevisions

func (e *Explorer) ContractRevisions(id types.FileContractID) (result []ExtendedFileContract, err error)

ContractRevisions returns all the revisions of the contract with the specified ID.

func (*Explorer) Contracts

func (e *Explorer) Contracts(ids []types.FileContractID) (result []ExtendedFileContract, err error)

Contracts returns the contracts with the specified IDs.

func (*Explorer) ContractsKey

func (e *Explorer) ContractsKey(key types.PublicKey) (result []ExtendedFileContract, err error)

ContractsKey returns the contracts for a particular ed25519 key.

func (*Explorer) Events

func (e *Explorer) Events(ids []types.Hash256) ([]Event, error)

Events returns the events with the specified IDs.

func (*Explorer) HostMetrics

func (e *Explorer) HostMetrics() (HostMetrics, error)

HostMetrics returns various metrics about currently available hosts.

func (*Explorer) Hosts

func (e *Explorer) Hosts(pks []types.PublicKey) ([]Host, error)

Hosts returns the hosts with the specified public keys.

func (*Explorer) MerkleProof

func (e *Explorer) MerkleProof(leafIndex uint64) ([]types.Hash256, error)

MerkleProof returns the proof of a given leaf.

func (*Explorer) Metrics

func (e *Explorer) Metrics(id types.BlockID) (Metrics, error)

Metrics returns various metrics about Sia.

func (*Explorer) QueryHosts

func (e *Explorer) QueryHosts(params HostQuery, sortBy HostSortColumn, dir HostSortDir, offset, limit uint64) ([]Host, error)

QueryHosts returns the hosts matching the query parameters in the order specified by dir.

func (*Explorer) Search

func (e *Explorer) Search(id string) (SearchType, error)

Search returns the type of an element (siacoin element, siafund element, contract, v2 contract, transaction, v2 transaction, block, or host).

func (*Explorer) Shutdown

func (e *Explorer) Shutdown(ctx context.Context) error

Shutdown tries to close the scanning goroutines in the explorer.

func (*Explorer) SiacoinElements

func (e *Explorer) SiacoinElements(ids []types.SiacoinOutputID) (result []SiacoinOutput, err error)

SiacoinElements returns the siacoin elements with the specified IDs.

func (*Explorer) SiafundElements

func (e *Explorer) SiafundElements(ids []types.SiafundOutputID) (result []SiafundOutput, err error)

SiafundElements returns the siafund elements with the specified IDs.

func (*Explorer) Tip

func (e *Explorer) Tip() (types.ChainIndex, error)

Tip returns the tip of the best known valid chain.

func (*Explorer) TransactionChainIndices

func (e *Explorer) TransactionChainIndices(id types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error)

TransactionChainIndices returns the chain indices of the blocks the transaction was included in. If the transaction has not been included in any blocks, the result will be nil,nil.

func (*Explorer) Transactions

func (e *Explorer) Transactions(ids []types.TransactionID) ([]Transaction, error)

Transactions returns the transactions with the specified IDs.

func (*Explorer) UnconfirmedEvents

func (e *Explorer) UnconfirmedEvents(index types.ChainIndex, timestamp time.Time, v1 []types.Transaction, v2 []types.V2Transaction) ([]Event, error)

UnconfirmedEvents annotates a list of unconfirmed transactions.

func (*Explorer) UnspentSiacoinOutputs

func (e *Explorer) UnspentSiacoinOutputs(address types.Address, offset, limit uint64) ([]SiacoinOutput, error)

UnspentSiacoinOutputs returns the unspent siacoin outputs owned by the specified address.

func (*Explorer) UnspentSiafundOutputs

func (e *Explorer) UnspentSiafundOutputs(address types.Address, offset, limit uint64) ([]SiafundOutput, error)

UnspentSiafundOutputs returns the unspent siafund outputs owned by the specified address.

func (*Explorer) V2ContractRevisions

func (e *Explorer) V2ContractRevisions(id types.FileContractID) (result []V2FileContract, err error)

V2ContractRevisions returns all the revisions of the v2 contract with the specified ID.

func (*Explorer) V2Contracts

func (e *Explorer) V2Contracts(ids []types.FileContractID) (result []V2FileContract, err error)

V2Contracts returns the v2 contracts with the specified IDs.

func (*Explorer) V2ContractsKey

func (e *Explorer) V2ContractsKey(key types.PublicKey) (result []V2FileContract, err error)

V2ContractsKey returns the v2 contracts for a particular ed25519 key.

func (*Explorer) V2TransactionChainIndices

func (e *Explorer) V2TransactionChainIndices(id types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error)

V2TransactionChainIndices returns the chain indices of the blocks the transaction was included in. If the transaction has not been included in any blocks, the result will be nil,nil.

func (*Explorer) V2Transactions

func (e *Explorer) V2Transactions(ids []types.TransactionID) ([]V2Transaction, error)

V2Transactions returns the v2 transactions with the specified IDs.

type ExtendedFileContract

type ExtendedFileContract struct {
	Resolved bool `json:"resolved"`
	Valid    bool `json:"valid"`

	TransactionID types.TransactionID `json:"transactionID"`

	ConfirmationIndex         types.ChainIndex    `json:"confirmationIndex"`
	ConfirmationTransactionID types.TransactionID `json:"confirmationTransactionID"`

	ProofIndex         *types.ChainIndex    `json:"proofIndex"`
	ProofTransactionID *types.TransactionID `json:"proofTransactionID"`

	ID                 types.FileContractID    `json:"id"`
	Filesize           uint64                  `json:"filesize"`
	FileMerkleRoot     types.Hash256           `json:"fileMerkleRoot"`
	WindowStart        uint64                  `json:"windowStart"`
	WindowEnd          uint64                  `json:"windowEnd"`
	Payout             types.Currency          `json:"payout"`
	ValidProofOutputs  []ContractSiacoinOutput `json:"validProofOutputs"`
	MissedProofOutputs []ContractSiacoinOutput `json:"missedProofOutputs"`
	UnlockHash         types.Address           `json:"unlockHash"`
	RevisionNumber     uint64                  `json:"revisionNumber"`
}

A ExtendedFileContract is a FileContract with added fields for resolved/valid state, and when the transaction was confirmed and proved.

type FileContractRevision

type FileContractRevision struct {
	ParentID         types.FileContractID   `json:"parentID"`
	UnlockConditions types.UnlockConditions `json:"unlockConditions"`

	ExtendedFileContract
}

A FileContractRevision is a FileContract with extra fields for revision information.

type FileContractUpdate

type FileContractUpdate struct {
	FileContractElement types.FileContractElement
	Revision            *types.FileContractElement
	Resolved, Valid     bool

	ConfirmationTransactionID *types.TransactionID
	ProofTransactionID        *types.TransactionID
}

FileContractUpdate represents a file contract from a consensus update.

type Host

type Host struct {
	PublicKey      types.PublicKey    `json:"publicKey"`
	V2             bool               `json:"v2"`
	NetAddress     string             `json:"netAddress"`
	V2NetAddresses []chain.NetAddress `json:"v2NetAddresses,omitempty"`

	Location geoip.Location `json:"location"`

	KnownSince             time.Time `json:"knownSince"`
	LastScan               time.Time `json:"lastScan"`
	LastScanSuccessful     bool      `json:"lastScanSuccessful"`
	LastAnnouncement       time.Time `json:"lastAnnouncement"`
	TotalScans             uint64    `json:"totalScans"`
	SuccessfulInteractions uint64    `json:"successfulInteractions"`
	FailedInteractions     uint64    `json:"failedInteractions"`

	Settings   rhpv2.HostSettings   `json:"settings"`
	PriceTable rhpv3.HostPriceTable `json:"priceTable"`

	RHPV4Settings rhpv4.HostSettings `json:"rhpV4Settings"`
}

Host represents a host and the information gathered from scanning it.

type HostMetrics

type HostMetrics struct {
	// Number of hosts that were up as of there last scan
	ActiveHosts uint64 `json:"activeHosts"`
	// Total storage of all active hosts, in bytes
	TotalStorage uint64 `json:"totalStorage"`
	// Remaining storage of all active hosts, in bytes (storage utilization is
	// equal to TotalStorage - RemainingStorage)
	RemainingStorage uint64 `json:"remainingStorage"`

	Settings   rhpv2.HostSettings   `json:"settings"`
	PriceTable rhpv3.HostPriceTable `json:"priceTable"`
}

HostMetrics represents averages of scanned information from hosts.

type HostQuery

type HostQuery struct {
	V2                   *bool             `json:"v2,omitempty"`
	PublicKeys           []types.PublicKey `json:"publicKeys,omitempty"`
	MinUptime            *float64          `json:"minUptime,omitempty"`
	MinDuration          *uint64           `json:"minDuration,omitempty"`
	MaxStoragePrice      *types.Currency   `json:"maxStoragePrice,omitempty"`
	MaxContractPrice     *types.Currency   `json:"maxContractPrice,omitempty"`
	MaxUploadPrice       *types.Currency   `json:"maxUploadPrice,omitempty"`
	MaxDownloadPrice     *types.Currency   `json:"maxDownloadPrice,omitempty"`
	MaxBaseRPCPrice      *types.Currency   `json:"maxBaseRPCPrice,omitempty"`
	MaxSectorAccessPrice *types.Currency   `json:"maxSectorAccessPrice,omitempty"`
	AcceptContracts      *bool             `json:"acceptContracts,omitempty"`
	Online               *bool             `json:"online,omitempty"`
}

HostQuery defines the filter and sort parameters for querying hosts.

type HostScan

type HostScan struct {
	PublicKey types.PublicKey `json:"publicKey"`
	Location  geoip.Location  `json:"location"`
	Success   bool            `json:"success"`
	Timestamp time.Time       `json:"timestamp"`
	NextScan  time.Time       `json:"nextScan"`

	Settings   rhpv2.HostSettings   `json:"settings"`
	PriceTable rhpv3.HostPriceTable `json:"priceTable"`

	RHPV4Settings rhpv4.HostSettings `json:"rhpV4Settings"`
}

HostScan represents the results of a host scan.

type HostSortColumn

type HostSortColumn string

HostSortColumn represents the sorting column for host filtering.

const (
	// HostSortDateCreated sorts hosts in the order they were first announced.
	HostSortDateCreated HostSortColumn = "date_created"
	// HostSortNetAddress sorts hosts by their net address.
	HostSortNetAddress HostSortColumn = "net_address"
	// HostSortPublicKey sorts hosts by their public key
	HostSortPublicKey HostSortColumn = "public_key"
	// HostSortAcceptingContracts sorts hosts by whether they accept contracts.
	HostSortAcceptingContracts HostSortColumn = "accepting_contracts"
	// HostSortUptime sorts hosts by their uptime.
	HostSortUptime HostSortColumn = "uptime"
	// HostSortStoragePrice sorts hosts by their storage price.
	HostSortStoragePrice HostSortColumn = "storage_price"
	// HostSortContractPrice sorts hosts by their contract price.
	HostSortContractPrice HostSortColumn = "contract_price"
	// HostSortDownloadPrice sorts hosts by their download price.
	HostSortDownloadPrice HostSortColumn = "download_price"
	// HostSortUploadPrice sorts hosts by their upload price.
	HostSortUploadPrice HostSortColumn = "upload_price"
	// HostSortUsedStorage sorts hosts by their used storage.
	HostSortUsedStorage HostSortColumn = "used_storage"
	// HostSortTotalStorage sorts hosts by their total storage.
	HostSortTotalStorage HostSortColumn = "total_storage"
)

func (HostSortColumn) MarshalText

func (h HostSortColumn) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*HostSortColumn) UnmarshalText

func (h *HostSortColumn) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type HostSortDir

type HostSortDir string

HostSortDir represents the sorting direction for host filtering.

const (
	// HostSortAsc means sorting in ascending order.
	HostSortAsc HostSortDir = "asc"
	// HostSortDesc means sorting in descending order.
	HostSortDesc HostSortDir = "desc"
)

func (HostSortDir) MarshalText

func (h HostSortDir) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*HostSortDir) UnmarshalText

func (h *HostSortDir) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Metrics

type Metrics struct {
	// Current chain index
	Index types.ChainIndex `json:"index"`
	// Current difficulty
	Difficulty consensus.Work `json:"difficulty"`
	// Siafund pool value
	SiafundTaxRevenue types.Currency `json:"siafundTaxRevenue"`
	// Total announced hosts
	TotalHosts uint64 `json:"totalHosts"`
	// Number of leaves in the accumulator
	NumLeaves uint64 `json:"numLeaves"`
	// Number of active contracts
	ActiveContracts uint64 `json:"activeContracts"`
	// Number of failed contracts
	FailedContracts uint64 `json:"failedContracts"`
	// Number of successful contracts
	SuccessfulContracts uint64 `json:"successfulContracts"`
	// Current storage utilization, in bytes
	StorageUtilization uint64 `json:"storageUtilization"`
	// Current circulating supply
	CirculatingSupply types.Currency `json:"circulatingSupply"`
	// Total contract revenue
	ContractRevenue types.Currency `json:"contractRevenue"`
}

Metrics contains various statistics relevant to the health of the Sia network.

type ResolutionType

type ResolutionType string

A ResolutionType represents the type of a v2 file contract resolution.

const (
	// ResolutionTypeRenewal represents a file contract renewal.
	ResolutionTypeRenewal ResolutionType = "renewal"
	// ResolutionTypeStorageProof represents submission of a storage proof.
	ResolutionTypeStorageProof ResolutionType = "storageProof"
	// ResolutionTypeExpiration represents the expiration of a contract.
	ResolutionTypeExpiration ResolutionType = "expiration"
)

type SearchType

type SearchType string

A SearchType represents the type of element found during a search.

const (
	// SearchTypeInvalid means we were unable to find any element with the
	// given identifier.
	SearchTypeInvalid SearchType = "invalid"
	// SearchTypeAddress means we found an address with the given ID.
	SearchTypeAddress SearchType = "address"
	// SearchTypeBlock means we found a block with the given ID.
	SearchTypeBlock SearchType = "block"
	// SearchTypeTransaction means we found a transaction with the given ID.
	SearchTypeTransaction SearchType = "transaction"
	// SearchTypeV2Transaction means we found a v2 transaction with the given ID.
	SearchTypeV2Transaction SearchType = "v2Transaction"
	// SearchTypeSiacoinElement means we found a siacoin element with the given
	// ID.
	SearchTypeSiacoinElement SearchType = "siacoinElement"
	// SearchTypeSiafundElement means we found a siafund element with the given
	// ID.
	SearchTypeSiafundElement SearchType = "siafundElement"
	// SearchTypeContract means we found a contract with the given ID.
	SearchTypeContract SearchType = "contract"
	// SearchTypeV2Contract means we found a V2 contract with the given ID.
	SearchTypeV2Contract SearchType = "v2contract"
	// SearchTypeHost means we found a host with the given pubkey.
	SearchTypeHost SearchType = "host"
)

type SiacoinInput

type SiacoinInput struct {
	Address types.Address  `json:"address"`
	Value   types.Currency `json:"value"`
	types.SiacoinInput
}

A SiacoinInput is a types.SiacoinInput with information about the parent value.

type SiacoinOutput

type SiacoinOutput struct {
	Source     Source            `json:"source"`
	SpentIndex *types.ChainIndex `json:"spentIndex"`
	types.SiacoinElement
}

A SiacoinOutput is a types.SiacoinElement with added fields for the source and when it was spent.

type SiafundInput

type SiafundInput struct {
	Address types.Address `json:"address"`
	Value   uint64        `json:"value"`
	types.SiafundInput
}

A SiafundInput is a types.SiafundInput with information about the parent value.

type SiafundOutput

type SiafundOutput struct {
	SpentIndex *types.ChainIndex `json:"spentIndex"`
	types.SiafundElement
}

A SiafundOutput is a types.SiafundElement with an added field for when it was spent.

type Source

type Source int

A Source represents where a siacoin output came from.

const (
	// SourceInvalid represents a source we are not aware of.
	SourceInvalid Source = iota
	// SourceMinerPayout means the source of the output is a miner payout.
	SourceMinerPayout
	// SourceTransaction means the source of the output is a transaction.
	SourceTransaction
	// SourceValidProofOutput me ans the source of the output is a valid proof
	// output.
	SourceValidProofOutput
	// SourceMissedProofOutput me ans the source of the output is a missed
	// proof output.
	SourceMissedProofOutput
)

func (Source) MarshalJSON

func (s Source) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Source) UnmarshalJSON

func (s *Source) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Store

type Store interface {
	Close() error

	UpdateChainState(reverted []chain.RevertUpdate, applied []chain.ApplyUpdate) error
	AddHostScans(scans []HostScan) error

	Tip() (types.ChainIndex, error)
	Block(id types.BlockID) (Block, error)
	BestTip(height uint64) (types.ChainIndex, error)
	MerkleProof(leafIndex uint64) ([]types.Hash256, error)
	Metrics(id types.BlockID) (Metrics, error)
	HostMetrics() (HostMetrics, error)
	Transactions(ids []types.TransactionID) ([]Transaction, error)
	TransactionChainIndices(txid types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error)
	V2Transactions(ids []types.TransactionID) ([]V2Transaction, error)
	V2TransactionChainIndices(txid types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error)
	UnspentSiacoinOutputs(address types.Address, offset, limit uint64) ([]SiacoinOutput, error)
	UnspentSiafundOutputs(address types.Address, offset, limit uint64) ([]SiafundOutput, error)
	UnconfirmedEvents(index types.ChainIndex, timestamp time.Time, v1 []types.Transaction, v2 []types.V2Transaction) (annotated []Event, err error)
	AddressEvents(address types.Address, offset, limit uint64) (events []Event, err error)
	Events([]types.Hash256) ([]Event, error)
	Balance(address types.Address) (sc types.Currency, immatureSC types.Currency, sf uint64, err error)
	Contracts(ids []types.FileContractID) (result []ExtendedFileContract, err error)
	ContractsKey(key types.PublicKey) (result []ExtendedFileContract, err error)
	ContractRevisions(id types.FileContractID) (result []ExtendedFileContract, err error)
	V2Contracts(ids []types.FileContractID) (result []V2FileContract, err error)
	V2ContractsKey(key types.PublicKey) (result []V2FileContract, err error)
	V2ContractRevisions(id types.FileContractID) (result []V2FileContract, err error)
	SiacoinElements(ids []types.SiacoinOutputID) (result []SiacoinOutput, err error)
	SiafundElements(ids []types.SiafundOutputID) (result []SiafundOutput, err error)
	Search(id string) (SearchType, error)

	QueryHosts(params HostQuery, sortBy HostSortColumn, dir HostSortDir, offset, limit uint64) ([]Host, error)
	HostsForScanning(minLastAnnouncement time.Time, limit uint64) ([]UnscannedHost, error)
}

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

type Transaction

type Transaction struct {
	ID types.TransactionID `json:"id"`

	SiacoinInputs         []SiacoinInput               `json:"siacoinInputs,omitempty"`
	SiacoinOutputs        []SiacoinOutput              `json:"siacoinOutputs,omitempty"`
	SiafundInputs         []SiafundInput               `json:"siafundInputs,omitempty"`
	SiafundOutputs        []SiafundOutput              `json:"siafundOutputs,omitempty"`
	FileContracts         []ExtendedFileContract       `json:"fileContracts,omitempty"`
	FileContractRevisions []FileContractRevision       `json:"fileContractRevisions,omitempty"`
	StorageProofs         []types.StorageProof         `json:"storageProofs,omitempty"`
	MinerFees             []types.Currency             `json:"minerFees,omitempty"`
	ArbitraryData         [][]byte                     `json:"arbitraryData,omitempty"`
	Signatures            []types.TransactionSignature `json:"signatures,omitempty"`

	HostAnnouncements []chain.HostAnnouncement `json:"hostAnnouncements,omitempty"`
}

A Transaction is a transaction that uses the wrapped types above.

func CoreToExplorerV1Transaction

func CoreToExplorerV1Transaction(txn types.Transaction) (result Transaction)

CoreToExplorerV1Transaction converts a core/types.Transaction to an event.Transaction. Fields we do not have information are unfilled in the return value.

type TreeNodeUpdate

type TreeNodeUpdate struct {
	Row    uint64
	Column uint64
	Hash   types.Hash256
}

A TreeNodeUpdate is a change to a merkle tree node.

type UnscannedHost

type UnscannedHost struct {
	PublicKey                types.PublicKey    `json:"publicKey"`
	V2                       bool               `json:"v2"`
	NetAddress               string             `json:"netAddress"`
	V2NetAddresses           []chain.NetAddress `json:"v2NetAddresses,omitempty"`
	FailedInteractionsStreak uint64             `json:"failedInteractionsStreak"`
}

UnscannedHost represents the metadata needed to scan a host.

func (UnscannedHost) IsV2

func (h UnscannedHost) IsV2() bool

IsV2 returns whether a host supports V2 or not.

func (UnscannedHost) V2SiamuxAddr

func (h UnscannedHost) V2SiamuxAddr() (string, bool)

V2SiamuxAddr returns the `Address` of the first TCP siamux `NetAddress` it finds in the host's list of net addresses. The protocol for this address is ProtocolTCPSiaMux.

type UpdateState

type UpdateState struct {
	Block             types.Block
	ChainIndexElement types.ChainIndexElement

	Events      []Event
	Metrics     Metrics
	TreeUpdates []TreeNodeUpdate

	HostAnnouncements   []chain.HostAnnouncement
	V2HostAnnouncements []V2HostAnnouncement

	NewSiacoinElements       []SiacoinOutput
	SpentSiacoinElements     []SiacoinOutput
	EphemeralSiacoinElements []SiacoinOutput

	NewSiafundElements       []types.SiafundElement
	SpentSiafundElements     []types.SiafundElement
	EphemeralSiafundElements []types.SiafundElement

	FileContractElements   []FileContractUpdate
	V2FileContractElements []V2FileContractUpdate
}

An UpdateState contains information relevant to the block being applied or reverted.

type UpdateTx

type UpdateTx interface {
	Metrics(height uint64) (Metrics, error)
	HostExists(pubkey types.PublicKey) (bool, error)

	ApplyIndex(state UpdateState) error
	RevertIndex(state UpdateState) error
}

An UpdateTx atomically updates the state of a store.

type V2BlockData

type V2BlockData struct {
	Height       uint64          `json:"height"`
	Commitment   types.Hash256   `json:"commitment"`
	Transactions []V2Transaction `json:"transactions"`
}

V2BlockData is a struct containing the fields from types.V2BlockData and our modified explorer.V2Transaction type.

type V2FileContract

type V2FileContract struct {
	TransactionID types.TransactionID `json:"transactionID"`

	ConfirmationIndex         types.ChainIndex    `json:"confirmationIndex"`
	ConfirmationTransactionID types.TransactionID `json:"confirmationTransactionID"`

	ResolutionIndex         *types.ChainIndex    `json:"resolutionIndex"`
	ResolutionTransactionID *types.TransactionID `json:"resolutionTransactionID"`

	types.V2FileContractElement
}

A V2FileContract is a v2 file contract.

type V2FileContractRenewal

type V2FileContractRenewal struct {
	FinalRenterOutput types.SiacoinOutput `json:"finalRenterOutput"`
	FinalHostOutput   types.SiacoinOutput `json:"finalHostOutput"`
	RenterRollover    types.Currency      `json:"renterRollover"`
	HostRollover      types.Currency      `json:"hostRollover"`
	NewContract       V2FileContract      `json:"newContract"`

	// signatures cover above fields
	RenterSignature types.Signature `json:"renterSignature"`
	HostSignature   types.Signature `json:"hostSignature"`
}

A V2FileContractRenewal renews a file contract.

type V2FileContractResolution

type V2FileContractResolution struct {
	Parent     V2FileContract `json:"parent"`
	Type       ResolutionType `json:"string"`
	Resolution any            `json:"resolution"`
}

A V2FileContractResolution closes a v2 file contract's payment channel. There are four resolution types: renewwal, storage proof, finalization, and expiration.

type V2FileContractRevision

type V2FileContractRevision struct {
	Parent   V2FileContract `json:"parent"`
	Revision V2FileContract `json:"revision"`
}

A V2FileContractRevision is a V2 file contract revision with the explorer V2FileContract type.

type V2FileContractUpdate

type V2FileContractUpdate struct {
	FileContractElement types.V2FileContractElement
	Revision            *types.V2FileContractElement
	Resolution          types.V2FileContractResolutionType

	ConfirmationTransactionID *types.TransactionID
	ResolutionTransactionID   *types.TransactionID
}

V2FileContractUpdate represents a v2 file contract from a consensus update.

type V2HostAnnouncement

type V2HostAnnouncement struct {
	PublicKey types.PublicKey `json:"publicKey"`
	chain.V2HostAnnouncement
}

A V2HostAnnouncement is a types.V2HostAnnouncement list of net addresses with the host public key attached.

type V2Transaction

type V2Transaction struct {
	ID types.TransactionID `json:"id"`

	SiacoinInputs  []types.V2SiacoinInput `json:"siacoinInputs,omitempty"`
	SiacoinOutputs []SiacoinOutput        `json:"siacoinOutputs,omitempty"`
	SiafundInputs  []types.V2SiafundInput `json:"siafundInputs,omitempty"`
	SiafundOutputs []SiafundOutput        `json:"siafundOutputs,omitempty"`

	FileContracts           []V2FileContract           `json:"fileContracts,omitempty"`
	FileContractRevisions   []V2FileContractRevision   `json:"fileContractRevisions,omitempty"`
	FileContractResolutions []V2FileContractResolution `json:"fileContractResolutions,omitempty"`

	Attestations  []types.Attestation `json:"attestations,omitempty"`
	ArbitraryData []byte              `json:"arbitraryData,omitempty"`

	NewFoundationAddress *types.Address `json:"newFoundationAddress,omitempty"`
	MinerFee             types.Currency `json:"minerFee"`

	HostAnnouncements []V2HostAnnouncement `json:"hostAnnouncements,omitempty"`
}

A V2Transaction is a V2 transaction that uses the wrapped types above.

func CoreToExplorerV2Transaction

func CoreToExplorerV2Transaction(txn types.V2Transaction) (result V2Transaction)

CoreToExplorerV2Transaction converts a core/types.V2Transaction to an event.V2Transaction. Fields we do not have information are unfilled in the return value.

Jump to

Keyboard shortcuts

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