2023-09-03 23:47:09 +00:00
|
|
|
package p2p
|
|
|
|
|
|
|
|
import (
|
2024-03-21 07:14:45 +00:00
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/multiformats/go-multiaddr"
|
2023-10-05 07:05:02 +00:00
|
|
|
"google.golang.org/grpc"
|
2023-09-03 23:47:09 +00:00
|
|
|
"source.quilibrium.com/quilibrium/monorepo/go-libp2p-blossomsub/pb"
|
2023-10-09 04:52:19 +00:00
|
|
|
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
|
2023-09-03 23:47:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type PubSub interface {
|
|
|
|
PublishToBitmask(bitmask []byte, data []byte) error
|
2024-10-12 18:48:25 +00:00
|
|
|
Publish(address []byte, data []byte) error
|
|
|
|
Subscribe(bitmask []byte, handler func(message *pb.Message) error) error
|
2023-09-03 23:47:09 +00:00
|
|
|
Unsubscribe(bitmask []byte, raw bool)
|
|
|
|
GetPeerID() []byte
|
2023-09-25 02:43:35 +00:00
|
|
|
GetBitmaskPeers() map[string][]string
|
2023-09-10 23:29:17 +00:00
|
|
|
GetPeerstoreCount() int
|
|
|
|
GetNetworkPeersCount() int
|
2023-09-03 23:47:09 +00:00
|
|
|
GetRandomPeer(bitmask []byte) ([]byte, error)
|
2024-03-21 07:14:45 +00:00
|
|
|
GetMultiaddrOfPeerStream(
|
|
|
|
ctx context.Context,
|
|
|
|
peerId []byte,
|
|
|
|
) <-chan multiaddr.Multiaddr
|
2023-09-29 07:55:09 +00:00
|
|
|
GetMultiaddrOfPeer(peerId []byte) string
|
2023-10-05 07:05:02 +00:00
|
|
|
StartDirectChannelListener(
|
|
|
|
key []byte,
|
2024-03-01 07:12:31 +00:00
|
|
|
purpose string,
|
2023-10-05 07:05:02 +00:00
|
|
|
server *grpc.Server,
|
|
|
|
) error
|
2024-03-01 07:12:31 +00:00
|
|
|
GetDirectChannel(peerId []byte, purpose string) (*grpc.ClientConn, error)
|
2023-10-09 04:52:19 +00:00
|
|
|
GetNetworkInfo() *protobufs.NetworkInfoResponse
|
2023-11-01 03:45:20 +00:00
|
|
|
SignMessage(msg []byte) ([]byte, error)
|
|
|
|
GetPublicKey() []byte
|
|
|
|
GetPeerScore(peerId []byte) int64
|
|
|
|
SetPeerScore(peerId []byte, score int64)
|
2023-09-03 23:47:09 +00:00
|
|
|
}
|