From 705ea09692a2c2dfcc5b87dd4dab30460cc65931 Mon Sep 17 00:00:00 2001 From: kalipso Date: Tue, 8 Oct 2024 18:49:05 +0200 Subject: [PATCH] WIP experimenting with discovery --- cmd/ppassd/ppassd.go | 11 +++++------ storage/storage.go | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/ppassd/ppassd.go b/cmd/ppassd/ppassd.go index 50671b4..bbe99b8 100644 --- a/cmd/ppassd/ppassd.go +++ b/cmd/ppassd/ppassd.go @@ -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) diff --git a/storage/storage.go b/storage/storage.go index 013c172..13343fe 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -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 {