-
Notifications
You must be signed in to change notification settings - Fork 2
/
compose_swarm.go
44 lines (37 loc) · 846 Bytes
/
compose_swarm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package p2p
type askBidi[A Addr] interface {
Asker[A]
AskServer[A]
}
type composedSecureSwarm[A Addr, Pub any] struct {
Swarm[A]
Secure[A, Pub]
}
type composedAskSwarm[A Addr] struct {
Swarm[A]
askBidi[A]
}
type composedSecureAskSwarm[A Addr, Pub any] struct {
Swarm[A]
askBidi[A]
Secure[A, Pub]
}
func ComposeAskSwarm[A Addr](swarm Swarm[A], ask askBidi[A]) AskSwarm[A] {
return composedAskSwarm[A]{
Swarm: swarm,
askBidi: ask,
}
}
func ComposeSecureAskSwarm[A Addr, Pub any](swarm Swarm[A], ask askBidi[A], sec Secure[A, Pub]) SecureAskSwarm[A, Pub] {
return composedSecureAskSwarm[A, Pub]{
Swarm: swarm,
askBidi: ask,
Secure: sec,
}
}
func ComposeSecureSwarm[A Addr, Pub any](swarm Swarm[A], sec Secure[A, Pub]) SecureSwarm[A, Pub] {
return composedSecureSwarm[A, Pub]{
Swarm: swarm,
Secure: sec,
}
}