Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ci and lints #15

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ func main() {
// make the struct of seeds into a string
var allseeds []string
for _, seed := range seeds {
allseeds = append(allseeds, seed.ID+"@"+seed.Address)
allseeds = append(allseeds, seed.ID+"@"+seed.Address) //nolint:staticcheck
}

// allpeers is a slice of peers
var allpeers []string
// make the struct of peers into a string
for _, peer := range peers {
allpeers = append(allpeers, peer.ID+"@"+peer.Address)
allpeers = append(allpeers, peer.ID+"@"+peer.Address) //nolint:staticcheck
}

// set the configuration
Expand All @@ -102,9 +102,18 @@ func main() {
addrBookFilePath := filepath.Join(homeDir, seedConfig.AddrBookFile)

// Make folders
os.MkdirAll(filepath.Dir(nodeKeyFilePath), os.ModePerm)
os.MkdirAll(filepath.Dir(addrBookFilePath), os.ModePerm)
os.MkdirAll(filepath.Dir(configFilePath), os.ModePerm)
err = os.MkdirAll(filepath.Dir(nodeKeyFilePath), os.ModePerm)
if err != nil {
panic(err)
}
err = os.MkdirAll(filepath.Dir(addrBookFilePath), os.ModePerm)
if err != nil {
panic(err)
}
err = os.MkdirAll(filepath.Dir(configFilePath), os.ModePerm)
if err != nil {
panic(err)
}

logger.Info("Starting Seed Node for " + chain.ChainID + " on " + fmt.Sprint(port))
defer Start(*seedConfig)
Expand Down Expand Up @@ -191,17 +200,19 @@ func Start(seedConfig Config) {
panic(err)
}

go func() {
// Fire periodically
ticker := time.NewTicker(5 * time.Second)
/*
go func() {
// Fire periodically
ticker := time.NewTicker(5 * time.Second)

for {
select {
case <-ticker.C:
logger.Info("Peers list", "peers", sw.Peers().List())
for {
select {
case <-ticker.C:
logger.Info("Peers list", "peers", sw.Peers().List())
}
}
}
}()
}()
*/

sw.Wait()
}
Expand All @@ -222,7 +233,10 @@ func getchains() Chains {

var chains Chains

json.Unmarshal([]byte(body), &chains)
err = json.Unmarshal([]byte(body), &chains)
if err != nil {
fmt.Println(err)
}
return chains
}

Expand All @@ -242,6 +256,9 @@ func getchain(chainid string) Chain {

var chain Chain

json.Unmarshal([]byte(body), &chain)
err = json.Unmarshal([]byte(body), &chain)
if err != nil {
fmt.Println(err)
}
return chain
}