WIP experimenting with discovery
This commit is contained in:
@@ -16,11 +16,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
topicNameFlag = flag.String("topicName", "akdjlask-23klaj2idalj2-ajl2kjd3i-2ldakjd2", "name of topic to join")
|
||||
topicNameFlag = flag.String("topicName", "pentapass", "name of topic to join")
|
||||
dbPath = flag.String("db", "./db", "db file path")
|
||||
nameSpace = flag.String("namespace", "crdt", "namespace")
|
||||
logger = logging.Logger("globaldb")
|
||||
// topicName = "globaldb-example"
|
||||
// netTopic = "globaldb-example-net"
|
||||
// config = "globaldb-example"
|
||||
)
|
||||
@@ -58,10 +57,10 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//topic, err := ps.Join(*topicNameFlag)
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
_, err = ps.Join(*topicNameFlag)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
go storage.DiscoverPeers(ctx, h, dht)
|
||||
|
||||
|
||||
@@ -555,7 +555,8 @@ func CreateNamespace(ID string, storageHandler *StorageHandler) (*Namespace, err
|
||||
fmt.Printf("Creating Namespace %s\n", ID)
|
||||
err := storageHandler.PubSub.RegisterTopicValidator(
|
||||
ID, //== topicName
|
||||
func(ctx context.Context, _ peer.ID, msg *pubsub.Message) bool {
|
||||
func(ctx context.Context, id peer.ID, msg *pubsub.Message) bool {
|
||||
fmt.Printf("PubSubmsg TOPIC: %s, PEER: %s\n", ID, id)
|
||||
signer := msg.GetFrom()
|
||||
trusted := IsTrustedPeer(ctx, signer, ID, storageHandler.Config)
|
||||
if !trusted {
|
||||
@@ -653,8 +654,8 @@ func DiscoverPeers(ctx context.Context, h host.Host, dht *dht.IpfsDHT) {
|
||||
}
|
||||
|
||||
|
||||
fmt.Printf("Trying to connect to a peer with id %s", peer.ID.String())
|
||||
if h.Network().Connectedness(peer.ID) != network.Connected {
|
||||
fmt.Printf("Trying to connect to a peer with id %s\n", peer.ID.String())
|
||||
_, err = h.Network().DialPeer(ctx, peer.ID)
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user