merged node and traffic packages

This commit is contained in:
херетик
2023-01-31 10:47:50 +00:00
parent ee9618c4d3
commit a83bfb06ef
34 changed files with 247 additions and 256 deletions

View File

@@ -9,25 +9,25 @@ import (
"git-indra.lan/indra-labs/indra/pkg/util/slice"
)
func (en *Engine) forward(on *forward.Layer, b slice.Bytes,
func (eng *Engine) forward(on *forward.Layer, b slice.Bytes,
c *slice.Cursor, prev types.Onion) {
// forward the whole buffer received onwards. Usually there will be a
// crypt.Layer under this which will be unwrapped by the receiver.
if on.AddrPort.String() == en.Node.AddrPort.String() {
if on.AddrPort.String() == eng.Node.AddrPort.String() {
// it is for us, we want to unwrap the next part.
en.handleMessage(BudgeUp(b, *c), on)
eng.handleMessage(BudgeUp(b, *c), on)
} else {
switch on1 := prev.(type) {
case *crypt.Layer:
sess := en.FindSessionByHeader(on1.ToPriv)
sess := eng.FindSessionByHeader(on1.ToPriv)
if sess != nil {
en.DecSession(sess.ID,
en.RelayRate*lnwire.MilliSatoshi(len(b))/1024/1024,
eng.DecSession(sess.ID,
eng.RelayRate*lnwire.MilliSatoshi(len(b))/1024/1024,
false, "forward")
}
}
// we need to forward this message onion.
en.Send(on.AddrPort, b)
eng.Send(on.AddrPort, b)
}
}