From 00b29c35f57044bede66963f093630419c41437b Mon Sep 17 00:00:00 2001 From: Akilan Date: Fri, 11 Nov 2022 23:33:27 +0000 Subject: [PATCH] modified README file --- README.md | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a94973c..f9a1ada 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ - Simulate discovery and file transfer The following library spawns peernet nodes automatically and runs -each Peernet instance as a go routine. +each Peernet instance as a go routine. The library also +automatically generates root nodes and regular nodes and also +automatically points the regular nodes to root node. The setup is intended to be as simple as possible. ``` @@ -17,15 +19,39 @@ Run: ./Peernet-test-framework ``` -Extend to your Go project (Instructions coming soon) -``` -// import Test framework +Extend to your Go project (Sample Program to spawn Peernet nodes based on default settings) +```go +import ( + testframework "github.com/PeernetOfficial/Peernet-test-framework" + "github.com/gorilla/mux" +) -// Control config through function calls +func main() { -// Generate network and return Configs as a list +r := mux.NewRouter() -// Manipulate each Peernet instance -> Reference WebAPI -(Using as a pointers as they can be updated) -// -> Soon replaced as abstractions +// Get Config information +config, err := testframework.ConfigInit() +if err != nil { + fmt.Println(err) +} + +srv := &http.Server{ + Handler: r, + Addr: config.MainServerAddress, + // Good practice: enforce timeouts for servers you create! + WriteTimeout: 15 * time.Second, + ReadTimeout: 15 * time.Second, +} + +manager, err := config.RunManager() +if err != nil { + fmt.Println(err) +} + +fmt.Println(len(*manager)) + +// Lister for the main server +log.Fatal(srv.ListenAndServe()) +} ``` \ No newline at end of file