-
Notifications
You must be signed in to change notification settings - Fork 376
/
nativedriver.go
57 lines (39 loc) · 1.4 KB
/
nativedriver.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
45
46
47
48
49
50
51
52
53
54
55
56
57
package proximitytransport
type NativeDriver interface {
// Start the native driver
Start(localPID string)
// Stop the native driver
Stop()
// Check if the native driver is connected to the remote peer
DialPeer(remotePID string) bool
// Send data to the remote peer
SendToPeer(remotePID string, payload []byte) bool
// Close the connection with the remote peer
CloseConnWithPeer(remotePID string)
// Return the multiaddress protocol code
ProtocolCode() int
// Return the multiaddress protocol name
ProtocolName() string
// Return the default multiaddress
DefaultAddr() string
}
type NoopNativeDriver struct {
protocolCode int
protocolName string
defaultAddr string
}
func NewNoopNativeDriver(protocolCode int, protocolName, defaultAddr string) *NoopNativeDriver {
return &NoopNativeDriver{
protocolCode: protocolCode,
protocolName: protocolName,
defaultAddr: defaultAddr,
}
}
func (d *NoopNativeDriver) Start(_ string) {}
func (d *NoopNativeDriver) Stop() {}
func (d *NoopNativeDriver) DialPeer(_ string) bool { return false }
func (d *NoopNativeDriver) SendToPeer(_ string, _ []byte) bool { return false }
func (d *NoopNativeDriver) CloseConnWithPeer(_ string) {}
func (d *NoopNativeDriver) ProtocolCode() int { return d.protocolCode }
func (d *NoopNativeDriver) ProtocolName() string { return d.protocolName }
func (d *NoopNativeDriver) DefaultAddr() string { return d.defaultAddr }