Skip to content

Commit

Permalink
Merge mesh-node branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecuesta committed Oct 12, 2022
1 parent 9c1044c commit b85efd2
Show file tree
Hide file tree
Showing 22 changed files with 2,573 additions and 447 deletions.
24 changes: 23 additions & 1 deletion app/cmd/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ func init() {
startCmd.Flags().BoolVar(&profileApp, "profileApp", false, "expose cpu & memory profiling")
startCmd.Flags().BoolVar(&useCache, "useCache", false, "use cache")
startCmd.Flags().BoolVar(&forceSetValidatorsLean, "forceSetValidators", false, "reads your lean_pocket_user_key_file (lean_nodes_keys.json) and updates your last signed state/validator files before starting your node")
meshCmd.Flags().BoolVar(&simulateRelay, "simulateRelay", false, "would you like to be able to test your relays")
rootCmd.AddCommand(startCmd)
rootCmd.AddCommand(meshCmd)
rootCmd.AddCommand(resetCmd)
rootCmd.AddCommand(version)
rootCmd.AddCommand(stopCmd)
Expand Down Expand Up @@ -96,7 +98,7 @@ func start(cmd *cobra.Command, args []string) {
genesisType = app.TestnetGenesisType
}
tmNode := app.InitApp(datadir, tmNode, persistentPeers, seeds, remoteCLIURL, keybase, genesisType, useCache, forceSetValidatorsLean)
go rpc.StartRPC(app.GlobalConfig.PocketConfig.RPCPort, app.GlobalConfig.PocketConfig.RPCTimeout, simulateRelay, profileApp, allBlockTxs, app.GlobalConfig.PocketConfig.ChainsHotReload)
go rpc.StartRPC(app.GlobalConfig.PocketConfig.RPCPort, app.GlobalConfig.PocketConfig.RPCTimeout, simulateRelay, profileApp, allBlockTxs, app.GlobalConfig.PocketConfig.ChainsHotReload, app.GlobalConfig.PocketConfig.MeshNode)
// trap kill signals (2,3,15,9)
signalChannel := make(chan os.Signal, 1)
signal.Notify(signalChannel,
Expand All @@ -120,6 +122,26 @@ func start(cmd *cobra.Command, args []string) {
}()
}

var meshCmd = &cobra.Command{
Use: "start-mesh",
Short: "starts pocket-mesh daemon",
Long: `Starts the Pocket mesh node, picks up the config from the assigned <datadir>`,
Run: func(cmd *cobra.Command, args []string) {
t := time.Unix(1625263200, 0) // Friday, July 2, 2021 6:00:00 PM GMT-04:00
sleepDuration := time.Until(t)
if time.Now().Before(t) {
fmt.Println("Sleeping for ", sleepDuration)
time.Sleep(sleepDuration)
}
startMesh(cmd, args)
},
}

func startMesh(cmd *cobra.Command, args []string) {
app.InitMeshConfig(datadir)
rpc.StartMeshRPC(simulateRelay)
}

// resetCmd represents the reset command
var resetCmd = &cobra.Command{
Use: "reset",
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Relay(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
WriteJSONResponseWithCode(w, string(j), r.URL.Path, r.Host, 400)
return
}
res, dispatch, err := app.PCA.HandleRelay(relay)
res, dispatch, err := app.PCA.HandleRelay(relay, false)
if err != nil {
response := RPCRelayErrorResponse{
Error: err,
Expand Down
Loading

0 comments on commit b85efd2

Please sign in to comment.