Documentation ¶
Index ¶
- func StandardCircuit() []byte
- type CircuitCache
- type Data
- type Manager
- func (sm *Manager) AddNodes(nn ...*node.Node)
- func (sm *Manager) AddPendingPayment(np *payments.Payment)
- func (sm *Manager) AddServiceToLocalNode(s *services.Service) (e error)
- func (sm *Manager) AddSession(s *sessions.Data)
- func (sm *Manager) ClearPendingPayments()
- func (sm *Manager) ClearSessions()
- func (sm *Manager) DecSession(id crypto.PubBytes, msats int, sender bool, typ string) bool
- func (sm *Manager) DeleteNodeAndSessions(id nonce.ID)
- func (sm *Manager) DeleteNodeByAddrPort(ip *netip.AddrPort) (e error)
- func (sm *Manager) DeleteNodeByID(ii nonce.ID) (e error)
- func (sm *Manager) DeletePendingPayment(preimage sha256.Hash)
- func (sm *Manager) DeleteSession(id crypto.PubBytes)
- func (sm *Manager) FindCloaked(clk crypto.CloakedPubKey) (hdr *crypto.Prv, pld *crypto.Prv, sess *sessions.Data, identity bool)
- func (sm *Manager) FindNodeByAddrPort(id *netip.AddrPort) (no *node.Node)
- func (sm *Manager) FindNodeByID(i nonce.ID) (no *node.Node)
- func (sm *Manager) FindNodeByIdentity(id *crypto.Pub) (no *node.Node)
- func (sm *Manager) FindNodeByIndex(i int) (no *node.Node)
- func (sm *Manager) FindPendingPayment(id nonce.ID) (pp *payments.Payment)
- func (sm *Manager) FindPendingPreimage(pi sha256.Hash) (pp *payments.Payment)
- func (sm *Manager) FindSessionByHeader(prvKey *crypto.Prv) *sessions.Data
- func (sm *Manager) FindSessionByHeaderPub(pubKey *crypto.Pub) *sessions.Data
- func (sm *Manager) FindSessionByPubkey(id crypto.PubBytes) *sessions.Data
- func (sm *Manager) FindSessionPreimage(pr sha256.Hash) *sessions.Data
- func (sm *Manager) ForEachNode(fn func(n *node.Node) bool)
- func (sm *Manager) GetLocalNode() *node.Node
- func (sm *Manager) GetLocalNodeAddress() (addr *netip.AddrPort)
- func (sm *Manager) GetLocalNodeAddressString() (s string)
- func (sm *Manager) GetLocalNodeIdentityBytes() (ident crypto.PubBytes)
- func (sm *Manager) GetLocalNodeIdentityPrv() (ident *crypto.Prv)
- func (sm *Manager) GetLocalNodePaymentChan() payments.PayChan
- func (sm *Manager) GetLocalNodeRelayRate() (rate uint32)
- func (sm *Manager) GetNodeCircuit(id nonce.ID) (sce *sessions.Circuit, exists bool)
- func (sm *Manager) GetSessionByIndex(i int) (s *sessions.Data)
- func (sm *Manager) GetSessionsAtHop(hop byte) (s sessions.Sessions)
- func (sm *Manager) IncSession(id crypto.PubBytes, msats lnwire.MilliSatoshi, sender bool, typ string)
- func (sm *Manager) IterateSessionCache(fn func(n *node.Node, c *sessions.Circuit) bool)
- func (sm *Manager) IterateSessions(fn func(s *sessions.Data) bool)
- func (sm *Manager) NodesLen() int
- func (sm *Manager) ReceiveToLocalNode() <-chan slice.Bytes
- func (sm *Manager) SelectHops(hops []byte, alreadyHave sessions.Sessions, note string) (so sessions.Sessions)
- func (sm *Manager) SelectUnusedCircuit() (c [5]*node.Node)
- func (sm *Manager) Send(addr *netip.AddrPort, s *splice.Splice)
- func (sm *Manager) SendFromLocalNode(port uint16, b slice.Bytes) (e error)
- func (sm *Manager) SendWithOneHook(ap *netip.AddrPort, res *Data, responseHook responses.Callback, ...)
- func (sm *Manager) SetLocalNode(n *node.Node)
- func (sm *Manager) SetLocalNodeAddress(addr *netip.AddrPort)
- func (sm *Manager) UpdateSessionCache()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StandardCircuit ¶
func StandardCircuit() []byte
StandardCircuit is a slice defining a standard circuit (5 is the return session).
Types ¶
type CircuitCache ¶
A CircuitCache stores each of the 5 hops of a peer node.
func (CircuitCache) Add ¶
func (sc CircuitCache) Add(s *sessions.Data) CircuitCache
type Manager ¶
type Manager struct { PendingPayments payments.PendingPayments sessions.Sessions CircuitCache sync.Mutex // contains filtered or unexported fields }
Manager is a session manager for Indra, handling sessions and services.
func NewSessionManager ¶
func NewSessionManager() *Manager
NewSessionManager creates a new session manager.
func (*Manager) AddPendingPayment ¶
AddPendingPayment adds a received incoming payment message to await the session keys.
func (*Manager) AddServiceToLocalNode ¶
AddServiceToLocalNode adds a service to the local node.
func (*Manager) AddSession ¶
AddSession adds a session to the session cache.
func (*Manager) ClearPendingPayments ¶
func (sm *Manager) ClearPendingPayments()
ClearPendingPayments is used only for debugging, removing all pending payments, making the engine forget about payments it received.
func (*Manager) ClearSessions ¶
func (sm *Manager) ClearSessions()
ClearSessions is used only for debugging, removing all but the first session, which is the engine's initial return session.
func (*Manager) DecSession ¶
DecSession decrements credit (mSat) on a session.
func (*Manager) DeleteNodeAndSessions ¶
DeleteNodeAndSessions deletes a node and all the sessions for it.
func (*Manager) DeleteNodeByAddrPort ¶
DeleteNodeByAddrPort deletes a node identified by a netip.AddrPort.
func (*Manager) DeleteNodeByID ¶
DeleteNodeByID deletes a node identified by an Keys.
func (*Manager) DeletePendingPayment ¶
DeletePendingPayment deletes a pending payment by the preimage hash.
func (*Manager) DeleteSession ¶
func (*Manager) FindCloaked ¶
func (sm *Manager) FindCloaked(clk crypto.CloakedPubKey) (hdr *crypto.Prv, pld *crypto.Prv, sess *sessions.Data, identity bool)
FindCloaked searches the client identity key and the sessions for a match. It returns the session as well, though not all users of this function will need this.
func (*Manager) FindNodeByAddrPort ¶
FindNodeByAddrPort searches for a Node by netip.AddrPort.
func (*Manager) FindNodeByID ¶
FindNodeByID searches for a Node by Keys.
func (*Manager) FindNodeByIdentity ¶
FindNodeByIdentity searches for a Node by netip.AddrPort.
func (*Manager) FindNodeByIndex ¶
FindNodeByIndex returns the node at a given position in the array.
func (*Manager) FindPendingPayment ¶
FindPendingPayment searches for a pending payment with the matching ID.
func (*Manager) FindPendingPreimage ¶
FindPendingPreimage searches for a pending payment with e matching preimage.
func (*Manager) FindSessionByHeader ¶
FindSessionByHeader searches for a session with a matching header private key.
func (*Manager) FindSessionByHeaderPub ¶
FindSessionByHeaderPub searches for a session with a matching header public key.
func (*Manager) FindSessionByPubkey ¶
FindSessionByPubkey searches for a session with a matching public key.
func (*Manager) FindSessionPreimage ¶
FindSessionPreimage searches for a session with a matching preimage hash.
func (*Manager) ForEachNode ¶
ForEachNode runs a function over the slice of nodes with the mutex locked, and terminates when the function returns true.
Do not call any Manager methods above inside this function or there will be a mutex double locking panic, except GetLocalNode.
func (*Manager) GetLocalNode ¶
GetLocalNode returns the engine's local Node.
func (*Manager) GetLocalNodeAddress ¶
GetLocalNodeAddress returns the AddrPort of the local node.
func (*Manager) GetLocalNodeAddressString ¶
GetLocalNodeAddressString returns the string form of the local node address.
func (*Manager) GetLocalNodeIdentityBytes ¶
GetLocalNodeIdentityBytes returns the public key bytes of the local node.
func (*Manager) GetLocalNodeIdentityPrv ¶
GetLocalNodeIdentityPrv returns the identity private key of the local node.
func (*Manager) GetLocalNodePaymentChan ¶
GetLocalNodePaymentChan returns the engine's local Node PayChan.
func (*Manager) GetLocalNodeRelayRate ¶
GetLocalNodeRelayRate returns the relay rate for the local node.
func (*Manager) GetNodeCircuit ¶
GetNodeCircuit gets the set of 5 sessions associated with a node with a given ID.
func (*Manager) GetSessionByIndex ¶
GetSessionByIndex returns the session with the given index in the main session cache.
func (*Manager) GetSessionsAtHop ¶
GetSessionsAtHop returns all of the sessions designated for a given hop in the circuit.
func (*Manager) IncSession ¶
func (sm *Manager) IncSession(id crypto.PubBytes, msats lnwire.MilliSatoshi, sender bool, typ string)
IncSession adds an amount of mSat to the balance of a session.
func (*Manager) IterateSessionCache ¶
IterateSessionCache calls a function for each entry in the CircuitCache that provides also access to the related node.
Do not call Manager methods within this function.
func (*Manager) IterateSessions ¶
IterateSessions calls a function for each entry in the Sessions slice.
Do not call Manager methods within this function.
func (*Manager) ReceiveToLocalNode ¶
ReceiveToLocalNode returns a channel that will receive messages for the local node, that arrived from the internet.
func (*Manager) SelectHops ¶
func (sm *Manager) SelectHops(hops []byte, alreadyHave sessions.Sessions, note string) (so sessions.Sessions)
SelectHops picks out a set of sessions to use in a circuit.
func (*Manager) SelectUnusedCircuit ¶
SelectUnusedCircuit accepts an array of 5 Node entries where all or some are empty and picks nodes for the remainder that do not have a hop at that position.
func (*Manager) SendFromLocalNode ¶
SendFromLocalNode delivers a message to a local service.
func (*Manager) SendWithOneHook ¶
func (sm *Manager) SendWithOneHook(ap *netip.AddrPort, res *Data, responseHook responses.Callback, p *responses.Pending)
SendWithOneHook is used for onions with only one confirmation hook. Usually as returned from PostAcctOnion this is the last, confirmation or response layer in an onion.Skins.
func (*Manager) SetLocalNode ¶
SetLocalNode sets the engine's local Node.
func (*Manager) SetLocalNodeAddress ¶
SetLocalNodeAddress changes the local node address.
func (*Manager) UpdateSessionCache ¶
func (sm *Manager) UpdateSessionCache()
UpdateSessionCache reads the main Sessions cache and populates the CircuitCache where circuits are aggregated.