libs5-go/service/p2p.go

32 lines
1.0 KiB
Go
Raw Normal View History

2024-01-06 11:33:46 +00:00
package service
import (
"git.lumeweb.com/LumeWeb/libs5-go/encoding"
"git.lumeweb.com/LumeWeb/libs5-go/net"
"git.lumeweb.com/LumeWeb/libs5-go/structs"
2024-01-09 11:58:03 +00:00
"git.lumeweb.com/LumeWeb/libs5-go/types"
2024-01-06 11:33:46 +00:00
"net/url"
"sync"
2024-01-06 11:33:46 +00:00
)
type P2PService interface {
SelfConnectionUris() []*url.URL
Peers() structs.Map
ConnectToNode(connectionUris []*url.URL, retry uint, fromPeer net.Peer) error
OnNewPeer(peer net.Peer, verifyId bool) error
GetNodeScore(nodeId *encoding.NodeId) (float64, error)
SortNodesByScore(nodes []*encoding.NodeId) ([]*encoding.NodeId, error)
SignMessageSimple(message []byte) ([]byte, error)
AddPeer(peer net.Peer) error
SendPublicPeersToPeer(peer net.Peer, peersToSend []net.Peer) error
SendHashRequest(hash *encoding.Multihash, kinds []types.StorageLocationType) error
UpVote(nodeId *encoding.NodeId) error
DownVote(nodeId *encoding.NodeId) error
NodeId() *encoding.NodeId
WaitOnConnectedPeers()
ConnectionTracker() *sync.WaitGroup
NetworkId() string
HashQueryRoutingTable() structs.Map
Service
}