bchd

package
v0.0.0-...-07a5fb3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReqContext

func NewReqContext(node Node) context.Context

Types

type BchdWatcher

type BchdWatcher struct {
	Nodes                        *Nodes
	BlocksBehindWarning          uint32
	LatestBlockWithin            time.Duration
	MaxDroppedConnectionsPerHour uint32
	// contains filtered or unexported fields
}

func NewBchdWatcher

func NewBchdWatcher(logger log.Logger, monitor *monitoring.HttpMonitoring) (*BchdWatcher, error)

func (*BchdWatcher) ReadGrpcStreams

func (w *BchdWatcher) ReadGrpcStreams(ctx context.Context)

type BestBlockHeight

type BestBlockHeight struct {
	BlockNumber uint32    `json:"block_number"`
	BlockTime   time.Time `json:"block_time"`
	Received    time.Time `json:"received"` // when WE saw this node got this block
}

type GRPCClient

type GRPCClient struct {
	Node   *Node
	Client pb.BchrpcClient
	// contains filtered or unexported fields
}

func NewGrpcClient

func NewGrpcClient(node Node, logger log.Logger, monitor *monitoring.HttpMonitoring) (grpcClient *GRPCClient, err error)

func (*GRPCClient) Close

func (gc *GRPCClient) Close() error

func (*GRPCClient) ReadTransactionStream

func (gc *GRPCClient) ReadTransactionStream(reqCtx context.Context, cancel context.CancelFunc) error

type Node

type Node struct {
	// config
	Address string `mapstructure:"Address"`

	AuthenticationToken string `mapstructure:"AuthenticationToken"` // gRPC metadata with auth token
	RootCertFile        string `mapstructure:"RootCertFile"`        // path to self-signed cert
	CaDomain            string `mapstructure:"CaDomain"`            // domain to validate certificate against (to override the domain in Address)
	AllowSelfSigned     bool   `mapstructure:"AllowSelfSigned"`

	Notify []notification.NotificationReceiver `mapstructure:"Notify"`
	// contains filtered or unexported fields
}

func (*Node) AddConnectError

func (n *Node) AddConnectError(err error)

Adds a connection error such as dropped gRPC stream. We use this to monitor reliability of nodes.

func (*Node) NotifyError

func (n *Node) NotifyError(msg string) error

Sends the error message to the operator(s) of this node.

func (*Node) SetBlockHeight

func (n *Node) SetBlockHeight(blockHeight uint32, timestamp time.Time)

func (*Node) SetConnected

func (n *Node) SetConnected()

func (*Node) SetLastReceive

func (n *Node) SetLastReceive()

type NodeConnectError

type NodeConnectError struct {
	When  time.Time `json:"when"`
	Error error     `json:"error"`
}

type NodeStats

type NodeStats struct {
	Connected       time.Time           `json:"connected"`
	LastReceive     time.Time           `json:"last_receive"`
	BlockHeight     BestBlockHeight     `json:"block_height"`
	LostConnections []*NodeConnectError `json:"lost_connections"`
	LastNotified    time.Time           `json:"last_notified"`
}

Node stats available via HTTP API as JSON

type Nodes

type Nodes struct {
	Nodes []*Node
}

func (*Nodes) GetBestBlockHeight

func (nodes *Nodes) GetBestBlockHeight() BestBlockHeight

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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