routetab

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolName           = "router"
	ProtocolVersion        = "4.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

type Options struct {
	Alpha int32
}

type Path

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

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

type PendingCallResArray

type PendingCallResArray []*PendCallResItem

type RelayStream

type RelayStream interface {
	GetNextHopRandomOrFind(ctx context.Context, target boson.Address, skips ...boson.Address) (next boson.Address, err error)
}

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) (addr *address.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

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

func (*Service) FindRoute

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

func (*Service) FindUnderlay

func (s *Service) FindUnderlay(ctx context.Context, target boson.Address) (addr *address.Address, err error)

func (*Service) GetNextHopRandomOrFind

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) Protocol

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

type Table

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

func (*Table) Delete

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

func (*Table) Gc

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

func (*Table) Get

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

func (*Table) GetNextHop

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

func (*Table) IterateTarget

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

func (*Table) ResumePaths

func (t *Table) ResumePaths()

func (*Table) ResumeRoutes

func (t *Table) ResumeRoutes()

func (*Table) SavePath

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

func (*Table) SavePaths

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

type TargetRoute

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