-
Notifications
You must be signed in to change notification settings - Fork 0
/
readonlyconnection.go
49 lines (38 loc) · 1 KB
/
readonlyconnection.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
package v2
import (
"errors"
"fmt"
"github.com/arobie1992/go-clarinet/v2/connection"
"github.com/arobie1992/go-clarinet/v2/peer"
)
type readOnlyConnection struct {
id connection.ID
sender peer.ID
witness peer.ID
receiver peer.ID
status connection.Status
}
func (c readOnlyConnection) String() string {
return fmt.Sprintf("{%s %s %s %s %s}", c.id, c.sender, c.witness, c.receiver, c.status)
}
func (c readOnlyConnection) ID() connection.ID {
return c.id
}
func (c readOnlyConnection) Receiver() peer.ID {
return c.receiver
}
func (c readOnlyConnection) Sender() peer.ID {
return c.sender
}
func (_ readOnlyConnection) SetStatus(status connection.Status) (connection.Connection, error) {
return nil, errors.ErrUnsupported
}
func (_ readOnlyConnection) SetWitness(peerID peer.ID) (connection.Connection, error) {
return nil, errors.ErrUnsupported
}
func (c readOnlyConnection) Status() connection.Status {
return c.status
}
func (c readOnlyConnection) Witness() peer.ID {
return c.witness
}