api

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: LGPL-3.0 Imports: 13 Imported by: 4 modules, 16 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultWriteTimeout = 10 * time.Second

DefaultWriteTimeout bounds each API response chunk write and each websocket message write. The semantics differ, see cmd/thor/httpserver and api/subscriptions.

Variables

This section is empty.

Functions

func ConvertEventFilter added in v2.3.1

func ConvertEventFilter(chain *chain.Chain, filter *EventFilter) (*logdb.EventFilter, error)

func ConvertRange added in v2.3.1

func ConvertRange(chain *chain.Chain, r *Range) (*logdb.Range, error)

func NormalizeOrder added in v2.5.1

func NormalizeOrder(o logdb.Order) (logdb.Order, error)

NormalizeOrder accepts "asc"/"desc" case-insensitively and returns asc for an empty order.

Types

type Account added in v2.3.1

type Account struct {
	Balance *math.HexOrDecimal256 `json:"balance"`
	Energy  *math.HexOrDecimal256 `json:"energy"`
	HasCode bool                  `json:"hasCode"`
}

Account for marshal account

type BatchCallData added in v2.3.1

type BatchCallData struct {
	Clauses    Clauses               `json:"clauses"`
	Gas        uint64                `json:"gas"`
	GasPrice   *math.HexOrDecimal256 `json:"gasPrice"`
	ProvedWork *math.HexOrDecimal256 `json:"provedWork"`
	Caller     *thor.Address         `json:"caller"`
	GasPayer   *thor.Address         `json:"gasPayer"`
	Expiration uint32                `json:"expiration"`
	BlockRef   string                `json:"blockRef"`
}

BatchCallData executes a batch of codes

type BatchCallResults added in v2.3.1

type BatchCallResults []*CallResult

type Beat2Message added in v2.3.1

type Beat2Message struct {
	Number        uint32                `json:"number"`
	ID            thor.Bytes32          `json:"id"`
	ParentID      thor.Bytes32          `json:"parentID"`
	Timestamp     uint64                `json:"timestamp"`
	TxsFeatures   uint32                `json:"txsFeatures"`
	BaseFeePerGas *math.HexOrDecimal256 `json:"baseFeePerGas,omitempty"`
	GasLimit      uint64                `json:"gasLimit"`
	Bloom         string                `json:"bloom"`
	K             uint8                 `json:"k"`
	Obsolete      bool                  `json:"obsolete"`
}

type BeatMessage added in v2.3.1

type BeatMessage struct {
	Number      uint32       `json:"number"`
	ID          thor.Bytes32 `json:"id"`
	ParentID    thor.Bytes32 `json:"parentID"`
	Timestamp   uint64       `json:"timestamp"`
	TxsFeatures uint32       `json:"txsFeatures"`
	Bloom       string       `json:"bloom"`
	K           uint32       `json:"k"`
	Obsolete    bool         `json:"obsolete"`
}

type BlockMessage added in v2.3.1

type BlockMessage struct {
	Number        uint32                `json:"number"`
	ID            thor.Bytes32          `json:"id"`
	Size          uint32                `json:"size"`
	ParentID      thor.Bytes32          `json:"parentID"`
	Timestamp     uint64                `json:"timestamp"`
	GasLimit      uint64                `json:"gasLimit"`
	Beneficiary   thor.Address          `json:"beneficiary"`
	GasUsed       uint64                `json:"gasUsed"`
	BaseFeePerGas *math.HexOrDecimal256 `json:"baseFeePerGas,omitempty"`
	TotalScore    uint64                `json:"totalScore"`
	TxsRoot       thor.Bytes32          `json:"txsRoot"`
	TxsFeatures   uint32                `json:"txsFeatures"`
	StateRoot     thor.Bytes32          `json:"stateRoot"`
	ReceiptsRoot  thor.Bytes32          `json:"receiptsRoot"`
	COM           bool                  `json:"com"`
	Signer        thor.Address          `json:"signer"`
	Transactions  []thor.Bytes32        `json:"transactions"`
	Obsolete      bool                  `json:"obsolete"`
}

BlockMessage block piped by websocket

func ConvertBlock added in v2.3.1

func ConvertBlock(b *chain.ExtendedBlock) (*BlockMessage, error)

type CallData added in v2.3.1

type CallData struct {
	Value    *math.HexOrDecimal256 `json:"value"`
	Data     string                `json:"data"`
	Gas      uint64                `json:"gas"`
	GasPrice *math.HexOrDecimal256 `json:"gasPrice"`
	Caller   *thor.Address         `json:"caller"`
}

CallData represents contract-call body

type CallResult added in v2.3.1

type CallResult struct {
	Data      string      `json:"data"`
	Events    []*Event    `json:"events"`
	Transfers []*Transfer `json:"transfers"`
	GasUsed   uint64      `json:"gasUsed"`
	Reverted  bool        `json:"reverted"`
	VMError   string      `json:"vmError"`
}

func ConvertCallResultWithInputGas added in v2.3.1

func ConvertCallResultWithInputGas(vo *runtime.Output, inputGas uint64) *CallResult

type Clause added in v2.3.1

type Clause struct {
	To    *thor.Address         `json:"to"`
	Value *math.HexOrDecimal256 `json:"value"`
	Data  string                `json:"data"`
}

Clause represents a transaction clause

func ConvertClause added in v2.3.1

func ConvertClause(c *tx.Clause) Clause

ConvertClause convert a raw clause into a json format clause

type Clauses added in v2.3.1

type Clauses []*Clause

Clauses array of clauses

type Event added in v2.3.1

type Event struct {
	Address thor.Address   `json:"address"`
	Topics  []thor.Bytes32 `json:"topics"`
	Data    string         `json:"data"`
}

Event represents a blockchain event

type EventCriteria added in v2.3.1

type EventCriteria struct {
	Address *thor.Address `json:"address"`
	TopicSet
}

type EventFilter added in v2.3.1

type EventFilter struct {
	CriteriaSet []*EventCriteria `json:"criteriaSet,omitempty"`
	Range       *Range           `json:"range,omitempty"`
	Options     *Options         `json:"options,omitempty"`
	Order       logdb.Order      `json:"order,omitempty"`
}

type EventMessage added in v2.3.1

type EventMessage struct {
	Address  thor.Address   `json:"address"`
	Topics   []thor.Bytes32 `json:"topics"`
	Data     string         `json:"data"`
	Meta     LogMeta        `json:"meta"`
	Obsolete bool           `json:"obsolete"`
}

EventMessage event piped by websocket

func ConvertSubscriptionEvent added in v2.3.1

func ConvertSubscriptionEvent(header *block.Header, tx *tx.Transaction, clauseIndex uint32, event *tx.Event, obsolete bool) (*EventMessage, error)

type FeesHistory added in v2.3.1

type FeesHistory struct {
	OldestBlock   thor.Bytes32     `json:"oldestBlock"`
	BaseFeePerGas []*hexutil.Big   `json:"baseFeePerGas"`
	GasUsedRatio  []float64        `json:"gasUsedRatio"`
	Reward        [][]*hexutil.Big `json:"reward,omitempty"`
}

type FeesPriority added in v2.3.1

type FeesPriority struct {
	MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
}

type FilteredEvent added in v2.3.1

type FilteredEvent struct {
	Address thor.Address    `json:"address"`
	Topics  []*thor.Bytes32 `json:"topics"`
	Data    string          `json:"data"`
	Meta    LogMeta         `json:"meta"`
}

FilteredEvent only comes from one contract

func ConvertEvent added in v2.3.1

func ConvertEvent(event *logdb.Event, addIndexes bool) *FilteredEvent

Convert a logdb.Event into a json format Event

type FilteredTransfer added in v2.3.1

type FilteredTransfer struct {
	Sender    thor.Address          `json:"sender"`
	Recipient thor.Address          `json:"recipient"`
	Amount    *math.HexOrDecimal256 `json:"amount"`
	Meta      LogMeta               `json:"meta"`
}

func ConvertTransfer added in v2.3.1

func ConvertTransfer(transfer *logdb.Transfer, addIndexes bool) *FilteredTransfer

type GetCodeResult added in v2.3.1

type GetCodeResult struct {
	Code string `json:"code"`
}

type GetRawStorageResponse added in v2.4.1

type GetRawStorageResponse struct {
	Value string `json:"value"`
}

type GetStorageResult added in v2.3.1

type GetStorageResult struct {
	Value string `json:"value"`
}

type HealthStatus added in v2.3.1

type HealthStatus struct {
	Healthy              bool       `json:"healthy"`
	BestBlockTime        *time.Time `json:"bestBlockTime"`
	PeerCount            int        `json:"peerCount"`
	IsNetworkProgressing bool       `json:"isNetworkProgressing"`
	NodeMaster           *string    `json:"nodeMaster"`
	Beneficiary          *string    `json:"beneficiary"`
}

type JSONBlockSummary added in v2.3.1

type JSONBlockSummary struct {
	Number        uint32                `json:"number"`
	ID            thor.Bytes32          `json:"id"`
	Size          uint32                `json:"size"`
	ParentID      thor.Bytes32          `json:"parentID"`
	Timestamp     uint64                `json:"timestamp"`
	GasLimit      uint64                `json:"gasLimit"`
	Beneficiary   thor.Address          `json:"beneficiary"`
	GasUsed       uint64                `json:"gasUsed"`
	TotalScore    uint64                `json:"totalScore"`
	TxsRoot       thor.Bytes32          `json:"txsRoot"`
	TxsFeatures   uint32                `json:"txsFeatures"`
	StateRoot     thor.Bytes32          `json:"stateRoot"`
	ReceiptsRoot  thor.Bytes32          `json:"receiptsRoot"`
	COM           bool                  `json:"com"`
	Signer        thor.Address          `json:"signer"`
	IsTrunk       bool                  `json:"isTrunk"`
	IsFinalized   bool                  `json:"isFinalized"`
	BaseFeePerGas *math.HexOrDecimal256 `json:"baseFeePerGas,omitempty"`
}

func BuildJSONBlockSummary added in v2.3.1

func BuildJSONBlockSummary(summary *chain.BlockSummary, isTrunk bool, isFinalized bool) *JSONBlockSummary

type JSONClause added in v2.3.1

type JSONClause struct {
	To    *thor.Address        `json:"to"`
	Value math.HexOrDecimal256 `json:"value"`
	Data  string               `json:"data"`
}

type JSONCollapsedBlock added in v2.3.1

type JSONCollapsedBlock struct {
	*JSONBlockSummary
	Transactions []thor.Bytes32 `json:"transactions"`
}

type JSONEmbeddedTx added in v2.3.1

type JSONEmbeddedTx struct {
	ID                   thor.Bytes32          `json:"id"`
	Type                 uint8                 `json:"type"`
	ChainTag             byte                  `json:"chainTag"`
	BlockRef             string                `json:"blockRef"`
	Expiration           uint32                `json:"expiration"`
	Clauses              Clauses               `json:"clauses"`
	GasPriceCoef         *uint8                `json:"gasPriceCoef,omitempty"`
	MaxFeePerGas         *math.HexOrDecimal256 `json:"maxFeePerGas,omitempty"`
	MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas,omitempty"`
	Gas                  uint64                `json:"gas"`
	Origin               thor.Address          `json:"origin"`
	Delegator            *thor.Address         `json:"delegator"`
	Nonce                math.HexOrDecimal64   `json:"nonce"`
	DependsOn            *thor.Bytes32         `json:"dependsOn"`
	Size                 uint32                `json:"size"`

	// receipt part
	GasUsed  uint64                `json:"gasUsed"`
	GasPayer thor.Address          `json:"gasPayer"`
	Paid     *math.HexOrDecimal256 `json:"paid"`
	Reward   *math.HexOrDecimal256 `json:"reward"`
	Reverted bool                  `json:"reverted"`
	Outputs  []*JSONOutput         `json:"outputs"`
}

func BuildJSONEmbeddedTxs added in v2.3.1

func BuildJSONEmbeddedTxs(txs tx.Transactions, receipts tx.Receipts) []*JSONEmbeddedTx

type JSONEvent added in v2.3.1

type JSONEvent struct {
	Address thor.Address   `json:"address"`
	Topics  []thor.Bytes32 `json:"topics"`
	Data    string         `json:"data"`
}

type JSONExpandedBlock added in v2.3.1

type JSONExpandedBlock struct {
	*JSONBlockSummary
	Transactions []*JSONEmbeddedTx `json:"transactions"`
}

type JSONOutput added in v2.3.1

type JSONOutput struct {
	ContractAddress *thor.Address   `json:"contractAddress"`
	Events          []*JSONEvent    `json:"events"`
	Transfers       []*JSONTransfer `json:"transfers"`
}

type JSONRawBlockSummary added in v2.3.1

type JSONRawBlockSummary struct {
	Raw string `json:"raw"`
}

type JSONTransfer added in v2.3.1

type JSONTransfer struct {
	Sender    thor.Address          `json:"sender"`
	Recipient thor.Address          `json:"recipient"`
	Amount    *math.HexOrDecimal256 `json:"amount"`
}

type LogLevelRequest added in v2.3.1

type LogLevelRequest struct {
	Level string `json:"level"`
}

type LogLevelResponse added in v2.3.1

type LogLevelResponse struct {
	CurrentLevel string `json:"currentLevel"`
}

type LogMeta added in v2.3.1

type LogMeta struct {
	BlockID        thor.Bytes32 `json:"blockID"`
	BlockNumber    uint32       `json:"blockNumber"`
	BlockTimestamp uint64       `json:"blockTimestamp"`
	TxID           thor.Bytes32 `json:"txID"`
	TxOrigin       thor.Address `json:"txOrigin"`
	ClauseIndex    uint32       `json:"clauseIndex"`
	TxIndex        *uint32      `json:"txIndex,omitempty"`
	LogIndex       *uint32      `json:"logIndex,omitempty"`
}

LogMeta represents metadata for logs

type LogStatus added in v2.3.1

type LogStatus struct {
	Enabled bool `json:"enabled"`
}

type Network added in v2.3.1

type Network interface {
	PeersStats() []*comm.PeerStats
}

type Options added in v2.3.1

type Options struct {
	Offset         uint64  `json:"offset,omitempty"`
	Limit          *uint64 `json:"limit,omitempty"`
	IncludeIndexes bool    `json:"includeIndexes,omitempty"`
}

func (*Options) Validate added in v2.3.2

func (o *Options) Validate(limit uint64, offset uint64) error

type Output added in v2.3.1

type Output struct {
	ContractAddress *thor.Address `json:"contractAddress"`
	Events          []*Event      `json:"events"`
	Transfers       []*Transfer   `json:"transfers"`
}

Output output of clause execution.

type PeerStats added in v2.3.1

type PeerStats struct {
	Name        string       `json:"name"`
	BestBlockID thor.Bytes32 `json:"bestBlockID"`
	TotalScore  uint64       `json:"totalScore"`
	PeerID      string       `json:"peerID"`
	NetAddr     string       `json:"netAddr"`
	Inbound     bool         `json:"inbound"`
	Duration    uint64       `json:"duration"`
}

func ConvertPeersStats added in v2.3.1

func ConvertPeersStats(ss []*comm.PeerStats) []*PeerStats

type PendingTxIDMessage added in v2.3.1

type PendingTxIDMessage struct {
	ID thor.Bytes32 `json:"id"`
}

type Range added in v2.3.1

type Range struct {
	Unit RangeType `json:"unit,omitempty"`
	From *uint64   `json:"from,omitempty"`
	To   *uint64   `json:"to,omitempty"`
}

func (*Range) Validate added in v2.3.2

func (r *Range) Validate() error

type RangeType added in v2.3.1

type RangeType string
const (
	BlockRangeType RangeType = "block"
	TimeRangeType  RangeType = "time"
)

type RawTransaction added in v2.3.1

type RawTransaction struct {
	RawTx
	Meta *TxMeta `json:"meta"`
}

type RawTx added in v2.3.1

type RawTx struct {
	Raw string `json:"raw"`
}

func (*RawTx) Decode added in v2.3.1

func (rtx *RawTx) Decode() (*tx.Transaction, error)

type Receipt added in v2.3.1

type Receipt struct {
	Type     uint8                 `json:"type,omitempty"`
	GasUsed  uint64                `json:"gasUsed"`
	GasPayer thor.Address          `json:"gasPayer"`
	Paid     *math.HexOrDecimal256 `json:"paid"`
	Reward   *math.HexOrDecimal256 `json:"reward"`
	Reverted bool                  `json:"reverted"`
	Meta     ReceiptMeta           `json:"meta"`
	Outputs  []*Output             `json:"outputs"`
}

Receipt for json marshal

func ConvertReceipt added in v2.3.1

func ConvertReceipt(txReceipt *tx.Receipt, header *block.Header, tx *tx.Transaction) (*Receipt, error)

ConvertReceipt convert a raw clause into a jason format clause

type ReceiptMeta added in v2.3.1

type ReceiptMeta struct {
	BlockID        thor.Bytes32 `json:"blockID"`
	BlockNumber    uint32       `json:"blockNumber"`
	BlockTimestamp uint64       `json:"blockTimestamp"`
	TxID           thor.Bytes32 `json:"txID"`
	TxOrigin       thor.Address `json:"txOrigin"`
}

type SendTxResult added in v2.3.1

type SendTxResult struct {
	ID *thor.Bytes32 `json:"id"`
}

SendTxResult is the response to the Send Tx method

type Status added in v2.3.1

type Status struct {
	Amount uint `json:"amount"`
}

type StorageEntry added in v2.3.1

type StorageEntry struct {
	Key   *thor.Bytes32 `json:"key"`
	Value *thor.Bytes32 `json:"value"`
}

type StorageMap added in v2.3.1

type StorageMap map[string]StorageEntry

type StorageRangeOption added in v2.3.1

type StorageRangeOption struct {
	Address   thor.Address
	KeyStart  string
	MaxResult int
	Target    string
}

type StorageRangeResult added in v2.3.1

type StorageRangeResult struct {
	Storage StorageMap    `json:"storage"`
	NextKey *thor.Bytes32 `json:"nextKey"` // nil if Storage includes the last key in the trie.
}

type SubscriptionEventFilter added in v2.3.1

type SubscriptionEventFilter struct {
	Address *thor.Address // restricts matches to events created by specific contracts
	Topic0  *thor.Bytes32
	Topic1  *thor.Bytes32
	Topic2  *thor.Bytes32
	Topic3  *thor.Bytes32
	Topic4  *thor.Bytes32
}

SubscriptionEventFilter contains options for contract event filtering.

func (*SubscriptionEventFilter) Match added in v2.3.1

func (ef *SubscriptionEventFilter) Match(event *tx.Event) bool

Match returs whether event matches filter

type SubscriptionTransferFilter added in v2.3.1

type SubscriptionTransferFilter struct {
	TxOrigin  *thor.Address // who send transaction
	Sender    *thor.Address // who transferred tokens
	Recipient *thor.Address // who received tokens
}

SubscriptionTransferFilter contains options for contract transfer filtering.

func (*SubscriptionTransferFilter) Match added in v2.3.1

func (tf *SubscriptionTransferFilter) Match(transfer *tx.Transfer, origin thor.Address) bool

Match returs whether transfer matches filter

type ToggleStatus added in v2.4.4

type ToggleStatus struct {
	Enabled    bool `json:"enabled"`
	TTLSeconds int  `json:"ttlSeconds,omitempty"`
}

ToggleStatus carries an enabled flag plus an optional TTL after which the flag will automatically be set back to false. A zero TTL means no auto-disable. Used by admin toggles like /admin/pprof and /admin/txpool-api.

type TopicSet added in v2.3.1

type TopicSet struct {
	Topic0 *thor.Bytes32 `json:"topic0"`
	Topic1 *thor.Bytes32 `json:"topic1"`
	Topic2 *thor.Bytes32 `json:"topic2"`
	Topic3 *thor.Bytes32 `json:"topic3"`
	Topic4 *thor.Bytes32 `json:"topic4"`
}

type TraceCallOption added in v2.3.1

type TraceCallOption struct {
	To         *thor.Address         `json:"to"`
	Value      *math.HexOrDecimal256 `json:"value"`
	Data       string                `json:"data"`
	Gas        uint64                `json:"gas"`
	GasPrice   *math.HexOrDecimal256 `json:"gasPrice"`
	ProvedWork *math.HexOrDecimal256 `json:"provedWork"`
	Caller     *thor.Address         `json:"caller"`
	GasPayer   *thor.Address         `json:"gasPayer"`
	Expiration uint32                `json:"expiration"`
	BlockRef   string                `json:"blockRef"`
	Name       string                `json:"name"`   // Tracer
	Config     json.RawMessage       `json:"config"` // Config specific to given tracer.
}

type TraceClauseOption added in v2.3.1

type TraceClauseOption struct {
	Name   string          `json:"name"`
	Target string          `json:"target"`
	Config json.RawMessage `json:"config"` // Config specific to given tracer.
}

type Transfer added in v2.3.1

type Transfer struct {
	Sender    thor.Address          `json:"sender"`
	Recipient thor.Address          `json:"recipient"`
	Amount    *math.HexOrDecimal256 `json:"amount"`
}

Transfer represents a token transfer

type TransferFilter added in v2.3.1

type TransferFilter struct {
	CriteriaSet []*logdb.TransferCriteria `json:"criteriaSet,omitempty"`
	Range       *Range                    `json:"range,omitempty"`
	Options     *Options                  `json:"options,omitempty"`
	Order       logdb.Order               `json:"order,omitempty"`
}

type TransferMessage added in v2.3.1

type TransferMessage struct {
	Sender    thor.Address          `json:"sender"`
	Recipient thor.Address          `json:"recipient"`
	Amount    *math.HexOrDecimal256 `json:"amount"`
	Meta      LogMeta               `json:"meta"`
	Obsolete  bool                  `json:"obsolete"`
}

TransferMessage transfer piped by websocket

func ConvertSubscriptionTransfer added in v2.3.1

func ConvertSubscriptionTransfer(header *block.Header, tx *tx.Transaction, clauseIndex uint32, transfer *tx.Transfer, obsolete bool) (*TransferMessage, error)

type TxMeta added in v2.3.1

type TxMeta struct {
	BlockID        thor.Bytes32 `json:"blockID"`
	BlockNumber    uint32       `json:"blockNumber"`
	BlockTimestamp uint64       `json:"blockTimestamp"`
}

Directories

Path Synopsis
featuregate
Package featuregate provides a generic runtime on/off toggle backed by an *atomic.Bool.
Package featuregate provides a generic runtime on/off toggle backed by an *atomic.Bool.
pprof
Package pprof wires net/http/pprof handlers under /debug/pprof/* on a gorilla/mux router root, gated by a featuregate.Gate so they only serve while pprof is enabled at runtime.
Package pprof wires net/http/pprof handlers under /debug/pprof/* on a gorilla/mux router root, gated by a featuregate.Gate so they only serve while pprof is enabled at runtime.
Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html>
Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html>

Jump to

Keyboard shortcuts

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