mirror of
https://github.com/dragonheim/gagent.git
synced 2025-01-18 09:36:28 -08:00
Adding support for a genesis DB.
This commit is contained in:
parent
d5fcd11592
commit
7a9225ce86
7 changed files with 35 additions and 4 deletions
13
assets/examples/agents/fib.tcl
Normal file
13
assets/examples/agents/fib.tcl
Normal file
|
@ -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]
|
18
assets/examples/agents/t2.tcl
Normal file
18
assets/examples/agents/t2.tcl
Normal file
|
@ -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]
|
||||||
|
}
|
|
@ -290,7 +290,7 @@ func init() {
|
||||||
if config.MonitorPort != 0 {
|
if config.MonitorPort != 0 {
|
||||||
go func() {
|
go func() {
|
||||||
log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort)
|
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))
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ func NewGagentDb() *GagentDb {
|
||||||
/*
|
/*
|
||||||
* Load the database from disk
|
* Load the database from disk
|
||||||
*/
|
*/
|
||||||
func (db *GagentDb) LoadHCL() error {
|
func (db *GagentDb) LoadHCL(ChainDBPath string) error {
|
||||||
err := hclsimple.DecodeFile("chaindb.hcl", nil, db)
|
err := hclsimple.DecodeFile(ChainDBPath, nil, db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
|
||||||
|
|
||||||
chain := gcdb.NewGagentDb()
|
chain := gcdb.NewGagentDb()
|
||||||
log.Println("[DEBUG] Loading chaindb ")
|
log.Println("[DEBUG] Loading chaindb ")
|
||||||
err := chain.LoadHCL()
|
err := chain.LoadHCL(config.ChainDBPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Error loading chaindb: %s", err)
|
log.Printf("[ERROR] Error loading chaindb: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue