api

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(l *zap.Logger) func(next http.Handler) http.Handler

Logger is a middleware that logs the start and end of each request, along with some useful data about what was requested, what the response status was, and how long it took to return.

func RollbackToHeight added in v0.5.0

func RollbackToHeight(app rollbackToHeight) http.HandlerFunc

func Run

func Run(ctx context.Context, address string, n *NodeApi) error

func WalletLoadKeys added in v0.5.0

func WalletLoadKeys(app walletLoadKeys) http.HandlerFunc

Types

type App

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

func NewApp

func NewApp(apiKey string, scheduler SchedulerEmits, services services.Services) (*App, error)

func (*App) Accounts added in v0.7.0

func (a *App) Accounts() ([]account, error)

func (*App) BlocksFirst

func (a *App) BlocksFirst() (*proto.Block, error)

func (*App) BlocksGenerators

func (a *App) BlocksGenerators() (Generators, error)

func (*App) BlocksLast

func (a *App) BlocksLast() (*proto.Block, error)

func (*App) BlocksScoreAt

func (a *App) BlocksScoreAt(at proto.Height) (*Score, error)

func (*App) DebugSyncEnabled added in v0.5.0

func (a *App) DebugSyncEnabled(enabled bool)

func (*App) LoadKeys added in v0.5.0

func (a *App) LoadKeys(apiKey string, password []byte) error

func (*App) Miner

func (a *App) Miner() (*MinerInfo, error)

func (*App) NodeProcesses added in v0.5.0

func (a *App) NodeProcesses() map[string]int

func (*App) PeersAll

func (a *App) PeersAll() (*PeersAll, error)

func (*App) PeersConnect

func (a *App) PeersConnect(ctx context.Context, apiKey string, addr string) (*PeersConnectResponse, error)

func (*App) PeersConnected

func (a *App) PeersConnected() (*PeersConnectedResponse, error)

func (*App) PeersSpawned

func (a *App) PeersSpawned() *PeersSpawnedResponse

func (*App) PeersSuspended

func (a *App) PeersSuspended() (*PeersSuspendedResponse, error)

func (*App) PoolTransactions added in v0.5.0

func (a *App) PoolTransactions() int

func (*App) RollbackToHeight added in v0.5.0

func (a *App) RollbackToHeight(apiKey string, height proto.Height) error

TODO Here should be internal message with rollback action

func (*App) TransactionsBroadcast

func (a *App) TransactionsBroadcast(ctx context.Context, b []byte) error

type AuthError

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

type BadRequestError

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

type BlockHeightResponse

type BlockHeightResponse struct {
	Height uint64 `json:"height"`
}

type Generator

type Generator struct {
	Height proto.Height     `json:"height"`
	PubKey crypto.PublicKey `json:"pub_key"`
}

type Generators

type Generators []Generator

type InternalError

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

type MinerInfo

type MinerInfo struct {
	Scheduler Scheduler
}

type Next

type Next struct {
	PublicKey crypto.PublicKey `json:"public_key"`
	Time      time.Time        `json:"time"`
}

type NodeApi

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

func NewNodeApi

func NewNodeApi(app *App, state state.State, node *node.Node) *NodeApi

func (*NodeApi) BlockAt

func (a *NodeApi) BlockAt(w http.ResponseWriter, r *http.Request)

func (*NodeApi) BlockHeight

func (a *NodeApi) BlockHeight(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) BlockIDAt added in v0.5.0

func (a *NodeApi) BlockIDAt(w http.ResponseWriter, r *http.Request)

func (*NodeApi) BlockScoreAt

func (a *NodeApi) BlockScoreAt(w http.ResponseWriter, r *http.Request)

func (*NodeApi) BlocksFirst

func (a *NodeApi) BlocksFirst(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) BlocksGenerators

func (a *NodeApi) BlocksGenerators(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) BlocksLast

func (a *NodeApi) BlocksLast(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) DebugSyncEnabled added in v0.5.0

func (a *NodeApi) DebugSyncEnabled(w http.ResponseWriter, r *http.Request)

func (*NodeApi) MinerInfo added in v0.7.0

func (a *NodeApi) MinerInfo(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) PeersAll

func (a *NodeApi) PeersAll(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) PeersConnect

func (a *NodeApi) PeersConnect(w http.ResponseWriter, r *http.Request)

func (*NodeApi) PeersConnected

func (a *NodeApi) PeersConnected(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) PeersSpawned

func (a *NodeApi) PeersSpawned(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) PeersSuspended

func (a *NodeApi) PeersSuspended(w http.ResponseWriter, _ *http.Request)

func (*NodeApi) TransactionsBroadcast

func (a *NodeApi) TransactionsBroadcast(w http.ResponseWriter, r *http.Request)

func (*NodeApi) WalletAccounts added in v0.7.0

func (a *NodeApi) WalletAccounts(w http.ResponseWriter, _ *http.Request)

type Peer

type Peer struct {
	Address  string `json:"address"`
	LastSeen uint64 `json:"lastSeen"`
}

type PeersAll

type PeersAll struct {
	Peers []Peer `json:"peers"`
}

type PeersConnectRequest

type PeersConnectRequest struct {
	Host string `json:"host"`
	Port uint16 `json:"port"`
}

type PeersConnectResponse

type PeersConnectResponse struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
}

type PeersConnectedResponse

type PeersConnectedResponse struct {
	Peers []PeersConnectedRow `json:"peers"`
}

type PeersConnectedRow

type PeersConnectedRow struct {
	Address            string `json:"address"`
	DeclaredAddress    string `json:"declaredAddress"`
	PeerName           string `json:"peerName"`
	PeerNonce          uint64 `json:"peerNonce"`
	ApplicationName    string `json:"applicationName"`
	ApplicationVersion string `json:"applicationVersion"`
}

type PeersSpawnedResponse

type PeersSpawnedResponse struct {
	Peers []proto.IpPort
}

type PeersSuspendedResponse

type PeersSuspendedResponse struct {
	Peers []string `json:"peers"`
}

type Scheduler

type Scheduler struct {
	TimeNow time.Time `json:"time_now"`
	Next    []Next    `json:"next"`
}

type SchedulerEmits

type SchedulerEmits interface {
	Emits() []scheduler.Emit
}

type Score

type Score struct {
	Score string `json:"score"`
}

Jump to

Keyboard shortcuts

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