@@ -20,7 +20,7 @@ use bytes::{Buf, BufMut, Bytes, BytesMut};
20
20
use futures_lite:: { Stream , StreamExt } ;
21
21
use futures_sink:: Sink ;
22
22
use futures_util:: SinkExt ;
23
- use iroh_base:: { PublicKey , SecretKey , Signature , PUBLIC_KEY_LENGTH } ;
23
+ use iroh_base:: { PublicKey , SecretKey , Signature } ;
24
24
use postcard:: experimental:: max_size:: MaxSize ;
25
25
use serde:: { Deserialize , Serialize } ;
26
26
use tokio_util:: codec:: { Decoder , Encoder } ;
@@ -268,15 +268,15 @@ impl Frame {
268
268
client_public_key : _,
269
269
message,
270
270
signature : _,
271
- } => MAGIC . len ( ) + PUBLIC_KEY_LENGTH + message. len ( ) + Signature :: BYTE_SIZE ,
272
- Frame :: SendPacket { dst_key : _, packet } => PUBLIC_KEY_LENGTH + packet. len ( ) ,
271
+ } => MAGIC . len ( ) + PublicKey :: LENGTH + message. len ( ) + Signature :: BYTE_SIZE ,
272
+ Frame :: SendPacket { dst_key : _, packet } => PublicKey :: LENGTH + packet. len ( ) ,
273
273
Frame :: RecvPacket {
274
274
src_key : _,
275
275
content,
276
- } => PUBLIC_KEY_LENGTH + content. len ( ) ,
276
+ } => PublicKey :: LENGTH + content. len ( ) ,
277
277
Frame :: KeepAlive => 0 ,
278
278
Frame :: NotePreferred { .. } => 1 ,
279
- Frame :: NodeGone { .. } => PUBLIC_KEY_LENGTH ,
279
+ Frame :: NodeGone { .. } => PublicKey :: LENGTH ,
280
280
Frame :: Ping { .. } => 8 ,
281
281
Frame :: Pong { .. } => 8 ,
282
282
Frame :: Health { problem } => problem. len ( ) ,
@@ -368,7 +368,7 @@ impl Frame {
368
368
let res = match frame_type {
369
369
FrameType :: ClientInfo => {
370
370
ensure ! (
371
- content. len( ) >= PUBLIC_KEY_LENGTH + Signature :: BYTE_SIZE + MAGIC . len( ) ,
371
+ content. len( ) >= PublicKey :: LENGTH + Signature :: BYTE_SIZE + MAGIC . len( ) ,
372
372
"invalid client info frame length: {}" ,
373
373
content. len( )
374
374
) ;
@@ -379,8 +379,8 @@ impl Frame {
379
379
380
380
let start = MAGIC . len ( ) ;
381
381
let client_public_key =
382
- PublicKey :: try_from ( & content[ start..start + PUBLIC_KEY_LENGTH ] ) ?;
383
- let start = start + PUBLIC_KEY_LENGTH ;
382
+ PublicKey :: try_from ( & content[ start..start + PublicKey :: LENGTH ] ) ?;
383
+ let start = start + PublicKey :: LENGTH ;
384
384
let signature =
385
385
Signature :: from_slice ( & content[ start..start + Signature :: BYTE_SIZE ] ) ?;
386
386
let start = start + Signature :: BYTE_SIZE ;
@@ -393,32 +393,32 @@ impl Frame {
393
393
}
394
394
FrameType :: SendPacket => {
395
395
ensure ! (
396
- content. len( ) >= PUBLIC_KEY_LENGTH ,
396
+ content. len( ) >= PublicKey :: LENGTH ,
397
397
"invalid send packet frame length: {}" ,
398
398
content. len( )
399
399
) ;
400
- let packet_len = content. len ( ) - PUBLIC_KEY_LENGTH ;
400
+ let packet_len = content. len ( ) - PublicKey :: LENGTH ;
401
401
ensure ! (
402
402
packet_len <= MAX_PACKET_SIZE ,
403
403
"data packet longer ({packet_len}) than max of {MAX_PACKET_SIZE}"
404
404
) ;
405
- let dst_key = PublicKey :: try_from ( & content[ ..PUBLIC_KEY_LENGTH ] ) ?;
406
- let packet = content. slice ( PUBLIC_KEY_LENGTH ..) ;
405
+ let dst_key = PublicKey :: try_from ( & content[ ..PublicKey :: LENGTH ] ) ?;
406
+ let packet = content. slice ( PublicKey :: LENGTH ..) ;
407
407
Self :: SendPacket { dst_key, packet }
408
408
}
409
409
FrameType :: RecvPacket => {
410
410
ensure ! (
411
- content. len( ) >= PUBLIC_KEY_LENGTH ,
411
+ content. len( ) >= PublicKey :: LENGTH ,
412
412
"invalid recv packet frame length: {}" ,
413
413
content. len( )
414
414
) ;
415
- let packet_len = content. len ( ) - PUBLIC_KEY_LENGTH ;
415
+ let packet_len = content. len ( ) - PublicKey :: LENGTH ;
416
416
ensure ! (
417
417
packet_len <= MAX_PACKET_SIZE ,
418
418
"data packet longer ({packet_len}) than max of {MAX_PACKET_SIZE}"
419
419
) ;
420
- let src_key = PublicKey :: try_from ( & content[ ..PUBLIC_KEY_LENGTH ] ) ?;
421
- let content = content. slice ( PUBLIC_KEY_LENGTH ..) ;
420
+ let src_key = PublicKey :: try_from ( & content[ ..PublicKey :: LENGTH ] ) ?;
421
+ let content = content. slice ( PublicKey :: LENGTH ..) ;
422
422
Self :: RecvPacket { src_key, content }
423
423
}
424
424
FrameType :: KeepAlive => {
@@ -436,7 +436,7 @@ impl Frame {
436
436
}
437
437
FrameType :: PeerGone => {
438
438
anyhow:: ensure!(
439
- content. len( ) == PUBLIC_KEY_LENGTH ,
439
+ content. len( ) == PublicKey :: LENGTH ,
440
440
"invalid peer gone frame length"
441
441
) ;
442
442
let peer = PublicKey :: try_from ( & content[ ..32 ] ) ?;
0 commit comments