renamed client and package to relay

This commit is contained in:
херетик
2023-01-29 11:33:20 +00:00
parent effc44030c
commit a14e7883dc
25 changed files with 25 additions and 25 deletions

View File

@@ -0,0 +1,33 @@
package relay
import (
"git-indra.lan/indra-labs/lnd/lnd/lnwire"
"git-indra.lan/indra-labs/indra/pkg/onion/layers/crypt"
"git-indra.lan/indra-labs/indra/pkg/onion/layers/forward"
"git-indra.lan/indra-labs/indra/pkg/types"
"git-indra.lan/indra-labs/indra/pkg/util/slice"
)
func (en *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() {
// it is for us, we want to unwrap the next part.
en.handleMessage(BudgeUp(b, *c), on)
} else {
switch on1 := prev.(type) {
case *crypt.Layer:
sess := en.FindSessionByHeader(on1.ToPriv)
if sess != nil {
log.D.Ln(on.AddrPort.String(), "forward forward")
en.DecSession(sess.ID,
en.RelayRate*lnwire.MilliSatoshi(len(b))/1024/1024)
}
}
// we need to forward this message onion.
en.Send(on.AddrPort, b)
}
}