P2PInterface represents a p2p network
| 34 | |
| 35 | // P2PInterface represents a p2p network |
| 36 | type P2PInterface interface { |
| 37 | GetIP() net.IP |
| 38 | GetID() []byte |
| 39 | SetPort(port string) |
| 40 | GetPort() string |
| 41 | Listen() error |
| 42 | Join(bootstrapIp []string) (num int, err error) |
| 43 | DisConnectTo(id []byte) error |
| 44 | Leave() |
| 45 | Request(ctx context.Context, id []byte, m proto.Message) (msg P2PMessage, err error) |
| 46 | Reply(ctx context.Context, id []byte, nonce uint64, m proto.Message) (err error) |
| 47 | SubscribeEvent() (subID int, outch chan discover.P2PEvent, err error) |
| 48 | UnSubscribeEvent(int) |
| 49 | SubscribeMsg(chanBuffer int, messages ...interface{}) (outch chan P2PMessage, err error) |
| 50 | UnSubscribeMsg(messages ...interface{}) |
| 51 | NumOfMembers() int |
| 52 | MembersID() [][]byte |
| 53 | RandomPeerIP() []string |
| 54 | //ConnectToAll(ctx context.Context, groupIds [][]byte, sessionID string) (out chan bool, errc chan error) |
| 55 | numOfClient() (int, int) |
| 56 | } |
| 57 | |
| 58 | // CreateP2PNetwork creates a P2PInterface implementation , gets a public IP and generates a secret key |
| 59 | func CreateP2PNetwork(id []byte, ip, port string, netType int) (P2PInterface, error) { |
no outgoing calls
no test coverage detected