routetab

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolName           = "router"
	ProtocolVersion        = "3.0.0"
	StreamOnRelay          = "relay"
	StreamOnRelayConnChain = "relayConnChain"
)

Variables

View Source
var (
	MaxTTL        int32 = 10
	NeighborAlpha int32 = 2
)
View Source
var (
	ErrNotFound = errors.New("route: not found")
)
View Source
var (
	PendingTimeout = time.Second * 5
)

Functions

This section is empty.

Types

type Options added in v1.2.0

type Options struct {
	Alpha int32
}

type Path added in v1.0.9

type Path struct {
	Sign       []byte          `json:"sign"`
	Bodys      [][]byte        `json:"bodys"`
	Items      []boson.Address `json:"items"`
	CreateTime time.Time       `json:"createTime"`
	UsedTime   time.Time       `json:"usedTime"`
}

type PendCallResItem added in v1.0.9

type PendCallResItem struct {
	Src        boson.Address
	CreateTime time.Time
	ResCh      chan struct{}
}

type PendingCallResArray added in v1.0.9

type PendingCallResArray []*PendCallResItem

type RelayStream added in v1.2.0

type RelayStream interface {
	GetNextHopRandomOrFind(ctx context.Context, target boson.Address, skips ...boson.Address) (next boson.Address, err error)
	PackRelayReq(ctx context.Context, stream p2p.VirtualStream, req *pb.RouteRelayReq)
	PackRelayResp(ctx context.Context, stream p2p.VirtualStream, req chan *pb.RouteRelayReq)
}

type RouteTab

type RouteTab interface {
	GetRoute(ctx context.Context, dest boson.Address) (paths []*Path, err error)
	FindRoute(ctx context.Context, dest boson.Address, timeout ...time.Duration) (paths []*Path, err error)
	DelRoute(ctx context.Context, dest boson.Address) (err error)
	Connect(ctx context.Context, dest boson.Address) error
	GetTargetNeighbor(ctx context.Context, dest boson.Address, limit int) (addresses []boson.Address, err error)
	IsNeighbor(dest boson.Address) (has bool)
	FindUnderlay(ctx context.Context, target boson.Address, timeouts ...time.Duration) (addr *aurora.Address, err error)
}

type Service

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

func New

func New(self boson.Address,
	ctx context.Context,
	p2ps p2p.Service,
	stream p2p.Streamer,
	addressbook addressbook.Interface,
	networkID uint64,
	lightNodes *lightnode.Container,
	kad *kademlia.Kad,
	store storage.StateStorer,
	logger logging.Logger,
	o Options) *Service

func (*Service) Close

func (s *Service) Close() error

Close implement for Closer Interface

func (*Service) Connect

func (s *Service) Connect(ctx context.Context, target boson.Address) error

func (*Service) DelRoute added in v1.0.9

func (s *Service) DelRoute(_ context.Context, target boson.Address) error

func (*Service) FindRoute

func (s *Service) FindRoute(ctx context.Context, target boson.Address, timeouts ...time.Duration) (paths []*Path, err error)

func (*Service) FindUnderlay added in v1.2.0

func (s *Service) FindUnderlay(ctx context.Context, target boson.Address, timeouts ...time.Duration) (addr *aurora.Address, err error)

func (*Service) GetNextHopRandomOrFind added in v1.2.0

func (s *Service) GetNextHopRandomOrFind(ctx context.Context, target boson.Address, skips ...boson.Address) (next boson.Address, err error)

func (*Service) GetRoute

func (s *Service) GetRoute(_ context.Context, dest boson.Address) ([]*Path, error)

func (*Service) GetTargetNeighbor

func (s *Service) GetTargetNeighbor(ctx context.Context, target boson.Address, limit int) (addresses []boson.Address, err error)

func (*Service) IsNeighbor

func (s *Service) IsNeighbor(dest boson.Address) (has bool)

func (*Service) Metrics

func (s *Service) Metrics() []prometheus.Collector

func (*Service) PackRelayReq added in v1.2.0

func (s *Service) PackRelayReq(ctx context.Context, stream p2p.VirtualStream, req *pb.RouteRelayReq)

PackRelayReq This packet mode is UDP mode and writing success does not mean that the final target has received a message

func (*Service) PackRelayResp added in v1.2.0

func (s *Service) PackRelayResp(ctx context.Context, stream p2p.VirtualStream, reqCh chan *pb.RouteRelayReq)

PackRelayResp This packet mode is UDP mode and writing success does not mean that the final target has received a message This channel is closed by the initiator node

func (*Service) Protocol

func (s *Service) Protocol() p2p.ProtocolSpec

type Table added in v1.0.9

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

func (*Table) Delete added in v1.0.9

func (t *Table) Delete(path *Path)

func (*Table) Gc added in v1.0.9

func (t *Table) Gc(expire time.Duration)

func (*Table) Get added in v1.0.9

func (t *Table) Get(target boson.Address) ([]*Path, error)

func (*Table) GetNextHop added in v1.0.9

func (t *Table) GetNextHop(target boson.Address, skips ...boson.Address) (next []boson.Address)

func (*Table) IterateTarget added in v1.2.0

func (t *Table) IterateTarget(items []boson.Address, fn func(target boson.Address))

func (*Table) ResumePaths added in v1.2.0

func (t *Table) ResumePaths()

func (*Table) ResumeRoutes added in v1.2.0

func (t *Table) ResumeRoutes()

func (*Table) SavePath added in v1.2.0

func (t *Table) SavePath(p *pb.Path)

func (*Table) SavePaths added in v1.2.0

func (t *Table) SavePaths(paths []*pb.Path)

type TargetRoute added in v1.2.0

type TargetRoute struct {
	Neighbor boson.Address // nextHop
	PathKey  common.Hash
}

Directories

Path Synopsis
Package pb holds only Protocol Buffer definitions and generated code.
Package pb holds only Protocol Buffer definitions and generated code.

Jump to

Keyboard shortcuts

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