routetab

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxTTL               uint8 = 10
	DefaultNeighborAlpha 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 Config

type Config struct {
	AddressBook addressbook.Interface
	NetworkID   uint64
	LightNodes  *lightnode.Container
	Stream      p2p.Streamer
}

type Index added in v1.0.9

type Index struct {
	NextHop boson.Address
	Sign    []byte
}

type Path added in v1.0.9

type Path struct {
	CreateTime int64           `json:"createTime"`
	Sign       []byte          `json:"sign"`
	Item       []boson.Address `json:"item"`
	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 Route added in v1.0.9

type Route struct {
	Index []Index
}

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

type Service

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

func New

func New(self boson.Address, ctx context.Context, p2ps p2p.Service, kad *kademlia.Kad, store storage.StateStorer, logger logging.Logger) *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(ctx 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) 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

func (*Service) SetConfig

func (s *Service) SetConfig(cfg Config)

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(dest boson.Address) ([]*Path, error)

func (*Table) GetNextHop added in v1.0.9

func (t *Table) GetNextHop(dest boson.Address, sign []byte) (next boson.Address)

func (*Table) ReqToResp added in v1.0.9

func (t *Table) ReqToResp(req *pb.RouteReq, paths []*Path) *pb.RouteResp

func (*Table) ReqToSave added in v1.0.9

func (t *Table) ReqToSave(req *pb.RouteReq) error

func (*Table) RespToSave added in v1.0.9

func (t *Table) RespToSave(resp *pb.RouteResp) error

func (*Table) RespToSaveOne added in v1.0.9

func (t *Table) RespToSaveOne(p *pb.Path) error

func (*Table) ResumeRoute added in v1.0.9

func (t *Table) ResumeRoute()

func (*Table) ResumeSigned added in v1.0.9

func (t *Table) ResumeSigned()

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