diff --git a/assets/examples/add-two.tcl b/assets/examples/agents/add-two.tcl similarity index 100% rename from assets/examples/add-two.tcl rename to assets/examples/agents/add-two.tcl diff --git a/assets/examples/agents/fib.tcl b/assets/examples/agents/fib.tcl new file mode 100644 index 0000000..8696b16 --- /dev/null +++ b/assets/examples/agents/fib.tcl @@ -0,0 +1,13 @@ +########################################## +### Perform Fibanaci sequence up to 10 ### +########################################## +set GHINT [split "math, fib" ,] +proc fib {x} { + if {<= $x 1} { + return 1 + } else { + + [fib [- $x 1]] [fib [- $x 2]] + } +} + +puts [fib 20] \ No newline at end of file diff --git a/assets/examples/hello-earth.tcl b/assets/examples/agents/hello-earth.tcl similarity index 100% rename from assets/examples/hello-earth.tcl rename to assets/examples/agents/hello-earth.tcl diff --git a/assets/examples/agents/t2.tcl b/assets/examples/agents/t2.tcl new file mode 100644 index 0000000..44b1533 --- /dev/null +++ b/assets/examples/agents/t2.tcl @@ -0,0 +1,18 @@ +########################################### +### Square numbers in sequence up to 10 ### +########################################### +set GHINT [split "math, square" ,] +proc square {x} { + * $x $x +} + +set a 1 +while {<= $a 10} { + if {== $a 5} { + puts {Missing five!} + set a [+ $a 1] + continue + } + puts "I can compute that $a*$a = [square $a]" + set a [+ $a 1] +} \ No newline at end of file diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 5516a3a..2101ab8 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -290,7 +290,7 @@ func init() { if config.MonitorPort != 0 { go func() { log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) - log.Fatal(http.ListenAndServe(string(config.ListenAddr)+strconv.Itoa(config.MonitorPort), nil)) + log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) }() } } diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 1941770..4b98516 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -38,8 +38,8 @@ func NewGagentDb() *GagentDb { /* * Load the database from disk */ -func (db *GagentDb) LoadHCL() error { - err := hclsimple.DecodeFile("chaindb.hcl", nil, db) +func (db *GagentDb) LoadHCL(ChainDBPath string) error { + err := hclsimple.DecodeFile(ChainDBPath, nil, db) if err != nil { return err } diff --git a/internal/router/router.go b/internal/router/router.go index 991418e..906f831 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -45,7 +45,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { chain := gcdb.NewGagentDb() log.Println("[DEBUG] Loading chaindb ") - err := chain.LoadHCL() + err := chain.LoadHCL(config.ChainDBPath) if err != nil { log.Printf("[ERROR] Error loading chaindb: %s", err) }