MCPcopy Create free account
hub / github.com/blues/note / PacketMaxDownlinkData

Method PacketMaxDownlinkData

lib/wire.go:2159–2184  ·  view source on GitHub ↗

PacketMaxDownlinkData returns the largest amount of data allowed

(encrypted bool)

Source from the content-addressed store, hash-verified

2157
2158// PacketMaxDownlinkData returns the largest amount of data allowed
2159func (h *PacketHandler) PacketMaxDownlinkData(encrypted bool) (length int) {
2160
2161 // Compute the length available
2162 length = int(h.Notecard.PacketDownlinkMtu)
2163
2164 // Packet flag byte
2165 length -= 1
2166
2167 // ConnectionID
2168 if h.Notecard.PacketCidType != CidNone {
2169 length -= len(h.Notehub.Cid)
2170 }
2171
2172 // If encrypted
2173 if encrypted {
2174 length -= 1 // MessagePort
2175 length -= ChaCha20Poly1305IvLen
2176 length -= ChaCha20Poly1305AuthTagLen
2177 } else {
2178 length -= 1 // MessagePort
2179 }
2180
2181 // Done
2182 return length
2183
2184}
2185
2186// PacketMaxUplinkData returns the largest amount of data allowed
2187func (h *PacketHandler) PacketMaxUplinkData(encrypted bool) (length int) {

Callers 1

PacketToWireMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected