route

package
v0.0.0-...-020e20f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ID is node id
	ID = "id."
	// PUBKEY is public key
	PUBKEY = "pub."
	// NONCE is nonce
	NONCE = "n."
	// ADDR is address
	ADDR = "addr."
)

Variables

View Source
var (
	// ErrUnknownNodeID indicates we got unknown node id
	ErrUnknownNodeID = errors.New("unknown node id")

	// ErrNilNodeID indicates we got nil node id
	ErrNilNodeID = errors.New("nil node id")
)
View Source
var (

	// Once is exported just for unit test
	Once utils.Once
)

Functions

func FromDomain

func FromDomain(domain string, f func(host string) ([]net.IP, error)) (out []byte, err error)

func FromIPv6

func FromIPv6(ips []net.IP) (out []byte, err error)

func GetBPs

func GetBPs() (bpAddrs []proto.NodeID)

GetBPs returns the known BP node id list.

func GetNodeAddrCache

func GetNodeAddrCache(id *proto.RawNodeID) (addr string, err error)

GetNodeAddrCache gets node addr by node id, if cache missed try RPC.

func InitKMS

func InitKMS(PubKeyStoreFile string)

InitKMS inits nasty stuff, only for testing.

func IsBPNodeID

func IsBPNodeID(id *proto.RawNodeID) bool

IsBPNodeID returns if it is Block Producer node id.

func IsPermitted

func IsPermitted(callerEnvelope *proto.Envelope, funcName RemoteFunc) (ok bool)

IsPermitted returns if the node is permitted to call the RPC func.

func SetNodeAddrCache

func SetNodeAddrCache(id *proto.RawNodeID, addr string) (err error)

SetNodeAddrCache sets node id and addr.

func ToIPv6

func ToIPv6(in []byte) (ips []net.IP, err error)

Types

type DHTService

type DHTService struct {
	Consistent *consistent.Consistent
}

DHTService is server side RPC implementation.

func NewDHTService

func NewDHTService(DHTStorePath string, persistImpl consistent.Persistence, initBP bool) (s *DHTService, err error)

NewDHTService will return a new DHTService.

func NewDHTServiceWithRing

func NewDHTServiceWithRing(c *consistent.Consistent) (s *DHTService, err error)

NewDHTServiceWithRing will return a new DHTService and set an existing hash ring.

func (*DHTService) FindNeighbor

func (DHT *DHTService) FindNeighbor(req *proto.FindNeighborReq, resp *proto.FindNeighborResp) (err error)

FindNeighbor RPC returns FindNeighborReq.Count closest node from DHT.

func (*DHTService) FindNode

func (DHT *DHTService) FindNode(req *proto.FindNodeReq, resp *proto.FindNodeResp) (err error)

FindNode RPC returns node with requested node id from DHT.

func (*DHTService) Nil

func (DHT *DHTService) Nil(req *interface{}, resp *interface{}) (err error)

Nil RPC does nothing just for probe.

func (*DHTService) Ping

func (DHT *DHTService) Ping(req *proto.PingReq, resp *proto.PingResp) (err error)

Ping RPC adds PingReq.Node to DHT.

type IDNodeMap

type IDNodeMap map[proto.RawNodeID]proto.Node

IDNodeMap is the map of proto.RawNodeID to node.

type IPv6SeedClient

type IPv6SeedClient struct{}

IPv6SeedClient is IPv6 DNS seed client

func (*IPv6SeedClient) GenBPIPv6

func (isc *IPv6SeedClient) GenBPIPv6(node *proto.Node, domain string) (out string, err error)

GenBPIPv6 generates the IPv6 addrs contain BP info

func (*IPv6SeedClient) GetBPFromDNSSeed

func (isc *IPv6SeedClient) GetBPFromDNSSeed(BPDomain string) (BPNodes IDNodeMap, err error)

GetBPFromDNSSeed gets BP info from the IPv6 domain

type NodeIDAddressMap

type NodeIDAddressMap map[proto.RawNodeID]string

NodeIDAddressMap is the map of proto.RawNodeID to node address.

type RemoteFunc

type RemoteFunc int

RemoteFunc defines the RPC Call name.

const (
	// DHTPing is for node info register to BP
	DHTPing RemoteFunc = iota
	// DHTFindNeighbor finds consistent hash neighbors
	DHTFindNeighbor
	// DHTFindNode gets node info
	DHTFindNode
	// DHTGSetNode is used by BP for dht data gossip
	DHTGSetNode
	// MetricUploadMetrics uploads node metrics
	MetricUploadMetrics
	// DBSQuery is used by client to read/write database
	DBSQuery
	// DBSAck is used by client to send acknowledge to the query response
	DBSAck
	// DBSDeploy is used by BP to create/drop/update database
	DBSDeploy
	// DBSObserverFetchBlock is used by observer to fetch block.
	DBSObserverFetchBlock
	// DBCCall is used by Miner for data consistency
	DBCCall
	// SQLCAdviseNewBlock is used by sqlchain to advise new block between adjacent node
	SQLCAdviseNewBlock
	// SQLCFetchBlock is used by sqlchain to fetch block from adjacent nodes
	SQLCFetchBlock
	// SQLCSignBilling is used by sqlchain to response billing signature for periodic billing request
	SQLCSignBilling
	// SQLCLaunchBilling is used by blockproducer to trigger the billing process in sqlchain
	SQLCLaunchBilling
	// MCCAdviseNewBlock is used by block producer to push block to adjacent nodes
	MCCAdviseNewBlock
	// MCCAdviseTxBilling is used by block producer to push billing transaction to adjacent nodes
	MCCAdviseTxBilling
	// MCCAdviseBillingRequest is used by block producer to push billing request to adjacent nodes
	MCCAdviseBillingRequest
	// MCCFetchBlock is used by nodes to fetch block from block producer
	MCCFetchBlock
	// MCCFetchBlockByCount is used by nodes to fetch block from block producer by block count since genesis
	MCCFetchBlockByCount
	// MCCFetchLastIrreversibleBlock is used by nodes to fetch last irreversible block from
	// block producer
	MCCFetchLastIrreversibleBlock
	// MCCFetchTxBilling is used by nodes to fetch billing transaction from block producer
	MCCFetchTxBilling
	// MCCNextAccountNonce is used by block producer main chain to allocate next nonce for transactions
	MCCNextAccountNonce
	// MCCAddTx is used by block producer main chain to upload transaction
	MCCAddTx
	// MCCQuerySQLChainProfile is used by nodes to query SQLChainProfile.
	MCCQuerySQLChainProfile
	// MCCQueryAccountTokenBalance is used by block producer to provide account token balance
	MCCQueryAccountTokenBalance
	// MCCQueryTxState is used by client to query transaction state.
	MCCQueryTxState
	// MCCQueryAccountSQLChainProfiles is used by client to query account databases.
	MCCQueryAccountSQLChainProfiles
	// MaxRPCOffset defines max rpc constant.
	MaxRPCOffset

	// DHTRPCName defines the block producer dh-rpc service name
	DHTRPCName = "DHT"
	// DHTGossipRPCName defines the block producer dh-rpc gossip service name
	DHTGossipRPCName = "DHTG"
	// BlockProducerRPCName defines main chain rpc name
	BlockProducerRPCName = "MCC"
	// SQLChainRPCName defines the sql chain rpc name
	SQLChainRPCName = "SQLC"
	// DBRPCName defines the sql chain db service rpc name
	DBRPCName = "DBS"
)

func (RemoteFunc) String

func (s RemoteFunc) String() string

String returns the RemoteFunc string.

type Resolver

type Resolver struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Resolver does NodeID translation.

Jump to

Keyboard shortcuts

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