Skip to content

Commit 66f93bf

Browse files
committed
feat: metrics draft
1 parent be5ebd4 commit 66f93bf

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

metrics.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ package noise
22

33
// metrics hold the statistics related to remote peers.
44
// We can add any method related to adaptive lookup logic here.
5+
// Please see [docs] for more information.
6+
//
7+
// [docs]: https://arxiv.org/pdf/1509.04417.pdf
58
type metrics struct {
6-
handshakeStart uint32
7-
handshakeEnd uint32
8-
latency uint16
9-
bandwidth uint16
9+
handshakeTime uint32 // how long took the handshake to complete.
10+
latency uint16 // rtt in ms
11+
bandwidth uint16 // remote peer bandwidth
12+
nonce uint16 // nonce ordering factor
13+
sent uint16 // sent messages
14+
recv uint16 // received messages
1015
}
1116

1217
// calculate weight
18+
// builder pattern?

peer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ type packet struct {
4242
}
4343

4444
// peer its the trusty remote peer.
45-
// Keep needed methods to interact with the secured session.
45+
// Provide needed methods to interact with the secured session.
4646
type peer struct {
4747
// the attributes orders matters.
4848
// ref: https://stackoverflow.com/questions/2113751/sizeof-struct-in-go
4949
id ID
5050
s *session
51-
l *metrics
51+
m *metrics
5252
pool BytePool
5353
}
5454

0 commit comments

Comments
 (0)