api

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(cm ChainManager, s Syncer, n Nodes, log *zap.Logger) http.Handler

Handler returns an http.Handler that serves the API.

Types

type ChainManager

type ChainManager interface {
	UpdatesSince(types.ChainIndex, int) ([]chain.RevertUpdate, []chain.ApplyUpdate, error)

	Tip() types.ChainIndex
	TipState() consensus.State
	AddBlocks([]types.Block) error
	PoolTransactions() []types.Transaction
	V2PoolTransactions() []types.V2Transaction
}

A ChainManager manages blockchain and txpool state.

type MineRequest

type MineRequest struct {
	Blocks  int           `json:"blocks"`
	Address types.Address `json:"address"`
}

MineRequest is the request type for [POST] /mine.

type Nodes

type Nodes interface {
	Nodes() []nodes.Node

	MineBlocks(ctx context.Context, n int, rewardAddress types.Address) error
	ProxyRequest(ctx context.Context, filter, httpMethod, path string, r io.Reader) ([]nodes.ProxyResponse, error)
}

Nodes manages the set of nodes in the cluster.

type ProxyResponse

type ProxyResponse struct {
	NodeID     nodes.NodeID    `json:"nodeID"`
	StatusCode int             `json:"statusCode"`
	Error      string          `json:"error,omitempty"`
	Data       nodes.ProxyData `json:"data"`
}

A ProxyResponse is the response for a proxied API request from a node.

type Syncer

type Syncer interface {
	BroadcastHeader(bh gateway.BlockHeader)
	BroadcastTransactionSet(txns []types.Transaction)
	BroadcastV2TransactionSet(index types.ChainIndex, txns []types.V2Transaction)
	BroadcastV2BlockOutline(bo gateway.V2BlockOutline)
}

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

Jump to

Keyboard shortcuts

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