server

package
v0.0.0-...-7ece11e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

func (Handler) GetPeers

func (s Handler) GetPeers(args string, responseMessagePeers *[]wire.RawPeer) error

func (Handler) Ping

func (s Handler) Ping(args *PingArgs, responseMessagePeers *[]wire.RawPeer) error

Ping - handler func which receive data from rpc client, add into list current peers and response all of them to client

type PingArgs

type PingArgs struct {
	RawAddress    string
	PublicKeyType string
	PublicKey     string
	SignData      string
}

func (*PingArgs) Init

func (ping *PingArgs) Init(RawAddress string, PublicKeyType string, PublicKey string, SignData string)

type RpcServer

type RpcServer struct {
	Config RpcServerConfig // config for RPC server
	// contains filtered or unexported fields
}

rpcServer provides a concurrent safe RPC server to a bootnode server.

func (*RpcServer) AddOrUpdatePeer

func (rpcServer *RpcServer) AddOrUpdatePeer(rawAddress string, publicKeyType string, publicKeyMining string, signDataB58 string) error

AddOrUpdatePeer - push a connected peer in to list of mem or update an old peer node

func (*RpcServer) CombineID

func (rpcServer *RpcServer) CombineID(rawAddress string, publicKey string) string

CombineID - return string = rawAddress of peer + public key in base58check encode of node(run as committee) in case node is not running like a committee, we dont have public key of user who running node from this, we can check who is committee in network from bootnode if node provide data for bootnode about key

func (*RpcServer) Init

func (rpcServer *RpcServer) Init(config *RpcServerConfig)

func (*RpcServer) PeerHeartBeat

func (rpcServer *RpcServer) PeerHeartBeat(heartbeatTimeout int)

PeerHeartBeat - loop forever after heartbeatInterval to check peers which are not connected to remove from bootnode use Last Ping time to compare with time.now

func (*RpcServer) RemovePeerByPbk

func (rpcServer *RpcServer) RemovePeerByPbk(publicKey string)

RemovePeerByPbk - remove peer from mem of bootnode

func (*RpcServer) Start

func (rpcServer *RpcServer) Start() error

Start - create handler and add into rpc server Listen and serve rpc server with config port

type RpcServerConfig

type RpcServerConfig struct {
	Port int // rpc port
}

Jump to

Keyboard shortcuts

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