api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(g Syncer, chain ChainManager, tp TPool, bench Benchmark, wallet Wallet, log *zap.Logger) http.Handler

NewServer initializes the API

Types

type Benchmark

type Benchmark interface {
	BenchmarkHost(ctx context.Context, hostAddr string, hostKey types.PublicKey, sectors uint64) (benchmark.Result, error)
	ScanHost(ctx context.Context, hostAddr string, hostKey types.PublicKey) (benchmark.Settings, error)
}

A Benchmark benchmarks hosts and manages contracts

type BenchmarkRequest

type BenchmarkRequest struct {
	Address string          `json:"address"`
	HostKey types.PublicKey `json:"hostKey"`
	Sectors uint64          `json:"sectors"`
}

A BenchmarkRequest initiates a benchmark with a host

type ChainManager

type ChainManager interface {
	Synced() bool
	TipState() consensus.State
}

A ChainManager retrieves the current blockchain state

type ConsensusState

type ConsensusState struct {
	Synced     bool             `json:"synced"`
	ChainIndex types.ChainIndex `json:"chainIndex"`
}

ConsensusState is the response body for the [GET] /consensus endpoint.

type Peer

type Peer struct {
	Address string `json:"address"`
	Version string `json:"version"`
}

A Peer is a peer in the network.

type ScanRequest

type ScanRequest struct {
	Address string          `json:"address"`
	HostKey types.PublicKey `json:"hostKey"`
}

A ScanRequest scans a host's settings and price table

type Syncer

type Syncer interface {
	Address() modules.NetAddress
	Peers() []modules.Peer
	Connect(addr modules.NetAddress) error
	Disconnect(addr modules.NetAddress) error
}

A Syncer can connect to other peers and synchronize the blockchain.

type SyncerConnectRequest

type SyncerConnectRequest struct {
	Address string `json:"address"`
}

SyncerConnectRequest is the request body for the [PUT] /syncer/peers endpoint.

type TPool

type TPool interface {
	RecommendedFee() (fee types.Currency)
	AcceptTransactionSet(txns []types.Transaction) error
}

A TPool manages the transaction pool

type Wallet

type Wallet interface {
	Address() types.Address
	ScanHeight() uint64
	Balance() (spendable, confirmed, unconfirmed types.Currency, err error)
	UnconfirmedTransactions() ([]wallet.Transaction, error)
	FundTransaction(txn *types.Transaction, amount types.Currency) (toSign []types.Hash256, release func(), err error)
	SignTransaction(cs consensus.State, txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields) error
	Transactions(limit, offset int) ([]wallet.Transaction, error)
}

A Wallet manages Siacoins and funds transactions

type WalletResponse

type WalletResponse struct {
	ScanHeight  uint64         `json:"scanHeight"`
	Address     types.Address  `json:"address"`
	Spendable   types.Currency `json:"spendable"`
	Confirmed   types.Currency `json:"confirmed"`
	Unconfirmed types.Currency `json:"unconfirmed"`
}

WalletResponse is the response body for the [GET] /wallet endpoint.

type WalletSendSiacoinsRequest

type WalletSendSiacoinsRequest struct {
	Address          types.Address  `json:"address"`
	Amount           types.Currency `json:"amount"`
	SubtractMinerFee bool           `json:"subtractMinerFee"`
}

WalletSendSiacoinsRequest is the request body for the [POST] /wallet/send endpoint.

Jump to

Keyboard shortcuts

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