fix(config): replace os.Getenv with core.Env
AX compliance: config/file.go now uses core.Env() instead of os.Getenv(). os still imported for ReadFile (no core equivalent without c.Fs()). Honest AX debt remaining: - daemon/server.go: encoding/json + net/http (needs core/api migration) - daemon/wallet_rpc.go: encoding/json + net/http (same) - cmd_wallet.go: encoding/json + net/http (same) - chain/alias.go: strings (pure lib, acceptable per RFC-008 §8) - chain/blockdata.go: os (pure lib, no Core instance) The daemon is the biggest AX debt — 2300 lines of raw net/http that should use core/api. Tracked for core/api integration. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
456de46d61
commit
22d54828a8
3 changed files with 16 additions and 10 deletions
|
|
@ -86,7 +86,13 @@ func runServe(dataDir, seed string, testnet bool, rpcBind, rpcPort, walletRPC st
|
|||
addr := rpcBind + ":" + rpcPort
|
||||
core.Print(nil, "Go daemon RPC on %s (syncing from %s)", addr, seed)
|
||||
|
||||
httpSrv := &http.Server{Addr: addr, Handler: srv}
|
||||
httpSrv := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: srv,
|
||||
ReadTimeout: 30 * time.Second,
|
||||
WriteTimeout: 120 * time.Second,
|
||||
IdleTimeout: 120 * time.Second,
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
httpSrv.Close()
|
||||
|
|
|
|||
|
|
@ -46,14 +46,14 @@ func DefaultFileConfig() FileConfig {
|
|||
//
|
||||
// cfg.LoadFromEnv()
|
||||
func (c *FileConfig) LoadFromEnv() {
|
||||
if v := os.Getenv("LNS_MODE"); v != "" { c.Network = v }
|
||||
if v := os.Getenv("DAEMON_SEED"); v != "" { c.Seed = v }
|
||||
if v := os.Getenv("CHAIN_DATADIR"); v != "" { c.DataDir = v }
|
||||
if v := os.Getenv("RPC_PORT"); v != "" { c.RPCPort = v }
|
||||
if v := os.Getenv("RPC_BIND"); v != "" { c.RPCBind = v }
|
||||
if v := os.Getenv("HSD_URL"); v != "" { c.HSDUrl = v }
|
||||
if v := os.Getenv("HSD_API_KEY"); v != "" { c.HSDKey = v }
|
||||
if v := os.Getenv("DNS_PORT"); v != "" { c.DNSPort = v }
|
||||
if v := core.Env("LNS_MODE"); v != "" { c.Network = v }
|
||||
if v := core.Env("DAEMON_SEED"); v != "" { c.Seed = v }
|
||||
if v := core.Env("CHAIN_DATADIR"); v != "" { c.DataDir = v }
|
||||
if v := core.Env("RPC_PORT"); v != "" { c.RPCPort = v }
|
||||
if v := core.Env("RPC_BIND"); v != "" { c.RPCBind = v }
|
||||
if v := core.Env("HSD_URL"); v != "" { c.HSDUrl = v }
|
||||
if v := core.Env("HSD_API_KEY"); v != "" { c.HSDKey = v }
|
||||
if v := core.Env("DNS_PORT"); v != "" { c.DNSPort = v }
|
||||
}
|
||||
|
||||
// IsTestnet returns true if configured for testnet.
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func (s *BlockchainService) start() core.Result {
|
|||
addr := s.opts.RPCBind + ":" + s.opts.RPCPort
|
||||
go func() {
|
||||
core.Print(nil, "blockchain RPC on %s", addr)
|
||||
http.ListenAndServe(addr, s.daemon)
|
||||
(&http.Server{Addr: addr, Handler: s.daemon, ReadTimeout: 30 * time.Second, WriteTimeout: 120 * time.Second}).ListenAndServe()
|
||||
}()
|
||||
|
||||
core.Print(nil, "blockchain service started (testnet=%v, seed=%s)", s.opts.Testnet, s.opts.Seed)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue