routing

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSimpleTable

func BuildSimpleTable(bvns []string) []protocol.Route

func RouteEnvelopes

func RouteEnvelopes(routeAccount func(*url.URL) (string, error), envs ...*messaging.Envelope) (string, error)

RouteEnvelopes routes envelopes based on the routing location of their signatures. RouteEnvelopes will return an error if the envelopes do not contain any signatures. RouteEnvelopes will return an error if the message bundle has signatures with conflicting routing locations.

func RouteMessages

func RouteMessages(r Router, messages []messaging.Message) (string, error)

RouteMessages routes the message bundle based on the routing location of its signatures. RouteMessages will return an error if the message bundle does not contain any signatures. RouteMessages will return an error if the message bundle has signatures with conflicting routing locations.

Types

type MessageRouter

type MessageRouter struct {
	Router Router
}

MessageRouter routes messages using a Router.

func (MessageRouter) Route

func (r MessageRouter) Route(msg message.Message) (multiaddr.Multiaddr, error)

Route routes a message.

type RouteTree

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

func NewRouteTree

func NewRouteTree(table *protocol.RoutingTable) (*RouteTree, error)

func (*RouteTree) Route

func (r *RouteTree) Route(u *url.URL) (string, error)

func (*RouteTree) RouteNr

func (r *RouteTree) RouteNr(n uint64) (string, error)

type Router

type Router interface {
	RouteAccount(*url.URL) (string, error)
	Route(...*messaging.Envelope) (string, error)
}

Router defines a basic interface for routing and sending transactions.

TODO Route and Send should probably be handled separately.

type RouterInstance

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

RouterInstance sends transactions to remote nodes via RPC calls.

func NewRouter

func NewRouter(opts RouterOptions) *RouterInstance

NewRouter constructs a new router. If an initial routing table is provided, the router will be initialized with that table. If an event bus is provided, the router will listen for changes. If no event bus is provided, the router will be static.

NewRouter will panic if the initial routing table is invalid. NewRouter will panic unless an initial routing table and/or event bus are specified.

func (*RouterInstance) Ready added in v1.4.0

func (r *RouterInstance) Ready() <-chan bool

func (*RouterInstance) Route

func (r *RouterInstance) Route(envs ...*messaging.Envelope) (string, error)

Route routes the account using modulo routing.

func (*RouterInstance) RouteAccount

func (r *RouterInstance) RouteAccount(account *url.URL) (string, error)

type RouterOptions added in v1.4.0

type RouterOptions struct {
	Initial *protocol.RoutingTable
	Events  *events.Bus
	Logger  log.Logger
}

Jump to

Keyboard shortcuts

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