api

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHeadersMiddleware added in v0.9.0

func CreateHeadersMiddleware(headers map[string]string) func(next http.Handler) http.Handler

func CreateLoggerMiddleware added in v0.9.0

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

CreateLoggerMiddleware creates 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 JsonContentTypeMiddleware added in v0.9.0

func JsonContentTypeMiddleware(next http.Handler) http.Handler

func Run

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

func RunWithOpts added in v0.9.0

func RunWithOpts(ctx context.Context, address string, n *NodeApi, opts *RunOptions) error

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) Addresses added in v0.9.0

func (a *App) Addresses() ([]string, error)

func (*App) BlocksFirst

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

func (*App) BlocksGenerators

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

func (*App) BlocksLast

func (a *App) BlocksLast() (*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) EthereumDAppMethods added in v0.10.0

func (a *App) EthereumDAppMethods(addr proto.WavesAddress) (ethabi.MethodsMap, error)

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

func (*App) NodeProcesses added in v0.5.0

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

func (*App) PeersAll

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

PeersAll is a list of all known not banned and not suspended peers with a publicly available declared address

func (*App) PeersConnect

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

func (*App) PeersConnected

func (a *App) PeersConnected() PeersConnectedResponse

func (*App) PeersKnown added in v0.9.0

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

func (*App) PeersSpawned

func (a *App) PeersSpawned() PeersSpawnedResponse

func (*App) PeersSuspended

func (a *App) PeersSuspended() []SuspendedPeerInfo

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 Block added in v0.10.0

type Block struct {
	*proto.Block
	Height proto.Height `json:"height"`
}

type ErrorHandler added in v0.9.0

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

func NewErrorHandler added in v0.9.0

func NewErrorHandler(logger *zap.Logger) ErrorHandler

func (*ErrorHandler) Handle added in v0.9.0

func (eh *ErrorHandler) Handle(w http.ResponseWriter, r *http.Request, err error)

type Generator

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

type Generators

type Generators []Generator

type HandleErrorFunc added in v0.9.0

type HandleErrorFunc func(w http.ResponseWriter, r *http.Request, err error)

type HandlerFunc added in v0.9.0

type HandlerFunc func(w http.ResponseWriter, r *http.Request) error

func RollbackToHeight added in v0.5.0

func RollbackToHeight(app rollbackToHeight) HandlerFunc

func WalletLoadKeys added in v0.5.0

func WalletLoadKeys(app walletLoadKeys) HandlerFunc

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) Addresses added in v0.9.0

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

func (*NodeApi) BlockAt

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

func (*NodeApi) BlockHeight

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

func (*NodeApi) BlockIDAt added in v0.5.0

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

func (*NodeApi) BlockScoreAt

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

func (*NodeApi) BlocksFirst

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

func (*NodeApi) BlocksGenerators

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

func (*NodeApi) BlocksLast

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

func (*NodeApi) EthereumDAppABI added in v0.10.0

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

func (*NodeApi) GoMinerInfo added in v0.9.0

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

func (*NodeApi) PeersAll

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

func (*NodeApi) PeersConnect

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

func (*NodeApi) PeersConnected

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

func (*NodeApi) PeersKnown added in v0.9.0

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

func (*NodeApi) PeersSpawned

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

func (*NodeApi) PeersSuspended

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

func (*NodeApi) TransactionsBroadcast

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

func (*NodeApi) WalletAccounts added in v0.7.0

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

type Peer

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

type PeerInfo added in v0.9.0

type PeerInfo 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 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 []PeerInfo `json:"peers"`
}

type PeersKnown added in v0.9.0

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

type PeersSpawnedResponse

type PeersSpawnedResponse struct {
	Peers []proto.IpPort `json:"peers"`
}

type RateLimiterOptions added in v0.9.0

type RateLimiterOptions struct {
	MemoryCacheSize      int
	MaxRequestsPerSecond int
	MaxBurst             int
}

type RunOptions added in v0.9.0

type RunOptions struct {
	RateLimiterOpts      *RateLimiterOptions
	LogHttpRequestOpts   bool
	CollectMetrics       bool
	UseRealIPMiddleware  bool
	EnableHeartbeatRoute bool
	RouteNotFoundHandler func(w http.ResponseWriter, r *http.Request)
}

func DefaultRunOptions added in v0.9.0

func DefaultRunOptions() *RunOptions

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"`
}

type SuspendedPeerInfo added in v0.9.0

type SuspendedPeerInfo struct {
	Hostname  string `json:"hostname"`
	Timestamp int64  `json:"timestamp"` // nickeskov: timestamp in millis
	Reason    string `json:"reason,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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