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,46 @@
package relay
import (
"git-indra.lan/indra-labs/lnd/lnd/lnwire"
"git-indra.lan/indra-labs/indra/pkg/onion/layers/response"
"git-indra.lan/indra-labs/indra/pkg/types"
"git-indra.lan/indra-labs/indra/pkg/util/slice"
)
// response is a payload from an exit message.
func (en *Engine) response(on *response.Layer, b slice.Bytes,
cur *slice.Cursor, prev types.Onion) {
pending := en.Pending.Find(on.ID)
log.T.F("searching for pending ID %x", on.ID)
first := true
var rr lnwire.MilliSatoshi
if pending != nil {
for i := range pending.Billable {
if first {
first = false
s := en.FindSession(pending.Billable[i])
for i := range s.Services {
if s.Services[i].Port == pending.Port {
rr = s.Services[i].RelayRate
}
}
if s != nil {
log.D.Ln(en.AddrPort.String(), "exit send", i)
en.DecSession(s.ID, rr*lnwire.
MilliSatoshi(len(b)/2)/1024/1024)
}
continue
}
s := en.FindSession(pending.Billable[i])
if s != nil {
log.D.Ln(en.AddrPort.String(), "reverse")
en.DecSession(s.ID, s.RelayRate*lnwire.
MilliSatoshi(len(b))/1024/1024)
}
}
pending.Callback(on.ID, on.Bytes)
en.Pending.Delete(on.ID)
}
}