github.com/aergoio/aergo@v1.3.1/types/rpc.go (about)

     1  /*
     2   * @file
     3   * @copyright defined in aergo/LICENSE.txt
     4   */
     5  
     6  package types
     7  
     8  import (
     9  	"errors"
    10  	"strconv"
    11  )
    12  
    13  var RPCErrInvalidArgument = errors.New("invalid argument")
    14  var RPCErrInternalError = errors.New("internal error")
    15  
    16  func AddCategory(confs map[string]*ConfigItem, category string) *ConfigItem {
    17  	cat := &ConfigItem{Props: make(map[string]string)}
    18  	confs[category] = cat
    19  	return cat
    20  }
    21  
    22  func (ci *ConfigItem) AddInt(key string, value int) *ConfigItem {
    23  	ci.Add(key, strconv.Itoa(value))
    24  	return ci
    25  }
    26  
    27  func (ci *ConfigItem) AddBool(key string, value bool) *ConfigItem {
    28  	ci.Add(key, strconv.FormatBool(value))
    29  	return ci
    30  }
    31  
    32  func (ci *ConfigItem) AddFloat(key string, value float64) *ConfigItem {
    33  	ci.Add(key, strconv.FormatFloat(value, 'g', -1, 64))
    34  	return ci
    35  }
    36  
    37  func (ci *ConfigItem) Add(key, value string) *ConfigItem {
    38  	ci.Props[key] = value
    39  	return ci
    40  }