github.com/bigzoro/my_simplechain@v0.0.0-20240315012955-8ad0a2a29bb9/cmd/dummytx/config/config.go (about)

     1  package config
     2  
     3  import (
     4  	"encoding/json"
     5  	"io/ioutil"
     6  )
     7  
     8  type Config struct {
     9  	ChainId                  string   `json:"chain_id"`
    10  	SipeAddr                 string   `json:"sipe_addr"`
    11  	PrivateKey               string   `json:"private_key"`
    12  	Cert                     string   `json:"cert"`
    13  	CACerts                  []string `json:"ca_certs"`
    14  	SenderPrivateKey         []string `json:"sender_private_key"`
    15  	SenderPrivateKeyPassword []string `json:"sender_private_key_password"`
    16  	Receiver                 string   `json:"receiver"`
    17  	GasPriceLimit            int64    `json:"gas_price_limit"`
    18  	GasPrice                 int64    `json:"gas_price"`
    19  	DummyInternal            int64    `json:"dummy_internal"`
    20  	Monitor                  bool     `json:"monitor"`
    21  }
    22  
    23  func LoadConfig(f string) *Config {
    24  	raw, err := ioutil.ReadFile(f)
    25  	if err != nil {
    26  		panic(err)
    27  	}
    28  
    29  	config := Config{}
    30  	if err = json.Unmarshal(raw, &config); err != nil {
    31  		panic(err)
    32  	}
    33  
    34  	return &config
    35  }