bootnode

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UDP            = "udp"
	TCP            = "tcp"
	RouteGetSeeds  = "api/bootnode"
	RouteGetHeight = "api/height"
	RouteGetXroute = "api/xroute"
)
View Source
const (
	Succ = 0
)

Variables

View Source
var (
	LocalNodeType types.NodeType
)
View Source
var (
	MainnetBootnodes = []string{
		"https://39.97.128.184:443",
		"https://39.97.197.181:443",
		"https://120.55.156.239:443",
		"https://47.110.211.42:443",
		"https://47.91.221.28:443",
		"https://161.117.157.31:443",
	}
)

Functions

func GetBestBootNode

func GetBestBootNode() (bootNodeAddr string)

func GetBootNodesNum

func GetBootNodesNum() int

func GetCurrentHeightOfChain

func GetCurrentHeightOfChain(logger log.Logger) (height uint64, err error)

func GetLocalNodeType

func GetLocalNodeType() types.NodeType

func GetSeeds

func GetSeeds(bootSouce string, priv crypto.PrivKey, logger log.Logger) (nodes []*common.Node, localNodeType types.NodeType, err error)

func GetSeedsFromBootSvr

func GetSeedsFromBootSvr(bootSvr string, priv crypto.PrivKey, logger log.Logger) (nodes []*common.Node, localNodeType types.NodeType, err error)

func GetXroute added in v0.1.2

func GetXroute(logger log.Logger) (xroute []string, err error)

GetXroute req xroute from bootnode, return xroute array

func HttpGet

func HttpGet(addr string) ([]byte, error)

func HttpPost

func HttpPost(url string, request interface{}) ([]byte, error)

func HttpPost2

func HttpPost2(url string, request interface{}) ([]byte, error)

func HttpPostWithHeader

func HttpPostWithHeader(url string, data []byte, header map[string]string) ([]byte, error)

func RapNodes

func RapNodes(seeds []Rnode, logger log.Logger) (nodes []*common.Node)

func UpdateBootNode

func UpdateBootNode(bootNodes []string, logger log.Logger)

UpdateBootNode update MainnetBootnodes from bootnodeAddrs,bootnodeAddrs's format are like https://ip1:port1,https://ip2:port2

Types

type Endpoint

type Endpoint struct {
	IP   []string       `json:"ip"`
	Port map[string]int `json:"port"` //key:protocol(udp or tcp or http)
}

Endpoint network endpoint

func NewLocalEndpoint

func NewLocalEndpoint() (*Endpoint, error)

NewLocalEndpoint create network endpoint with local IPv4 address

type GetSeedsResp added in v0.1.2

type GetSeedsResp struct {
	Code    int     `json:"code"` //0:success,other:failed
	Message string  `json:"message"`
	Type    int     `json:"type"` //The identity type of this node, reference NodeType
	Seeds   []Rnode `json:"nodes"`
}

type Rnode

type Rnode struct {
	ID       common.NodeID `json:"id"` //TransPubKeyToNodeID
	Endpoint *Endpoint     `json:"endpoint,omitempty"`
}

Jump to

Keyboard shortcuts

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