conf

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2018 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppMajor uint = 0
	AppMinor uint = 0
	AppPatch uint = 7

	// AppPreRelease MUST only contain characters from semanticAlphabet
	// per the semantic versioning spec.
	AppPreRelease = "beta"
	AppName       = "Copernicus"
)
View Source
const (
	OneMegaByte = 1000000
)

Variables

View Source
var (
	Cfg     *Configuration
	Args    *Opts
	DataDir string
)

Functions

func AppDataDir

func AppDataDir(appName string, roaming bool) string

AppDataDir returns an operating system specific directory to be used for storing application data for an application.

The appName parameter is the name of the application the data directory is being requested for. This function will prepend a period to the appName for POSIX style operating systems since that is standard practice. An empty appName or one with a single dot is treated as requesting the current directory so only "." will be returned. Further, the first character of appName will be made lowercase for POSIX style operating systems and uppercase for Mac and Windows since that is standard practice.

The roaming parameter only applies to Windows where it specifies the roaming application data profile (%APPDATA%) should be used instead of the local one (%LOCALAPPDATA%) that is used by default.

Example results:

dir := AppDataDir("myapp", false)
 POSIX (Linux/BSD): ~/.myapp
 Mac OS: $HOME/Library/Application Support/Myapp
 Windows: %LOCALAPPDATA%\Myapp
 Plan 9: $home/myapp

func CopyFile

func CopyFile(src, des string) (w int64, err error)

func FileExists added in v0.0.3

func FileExists(datadir string) bool

func GetSubVersionEB added in v0.0.6

func GetSubVersionEB() string

GetSubVersionEB converts MaxBlockSize from byte to MB with a decimal precision one digit rounded down E.g. 1660000 -> 1.6 2010000 -> 2.0 1000000 -> 1.0 230000 -> 0.2 50000 -> 0.0 NB behavior for EB<1MB not standardized yet still the function applies the same algo used for EB greater or equal to 1MB

func GetUserAgent added in v0.0.6

func GetUserAgent(name string, version string, comments []string) string

func SetUnitTestDataDir added in v0.0.3

func SetUnitTestDataDir(config *Configuration) (dirPath string, err error)

Types

type Configuration

type Configuration struct {
	GoVersion          string `validate:"require"` //description:"Display version information and exit"
	Version            string `validate:"require"` //description:"Display version information of copernicus"
	BuildDate          string `validate:"require"` //description:"Display build date of copernicus"
	DataDir            string `default:"data"`
	Reindex            bool
	Excessiveblocksize uint64

	// Service struct {
	// 	Address string `default:"1.0.0.1:80"`
	// }
	RPC struct {
		RPCListeners         []string // Add an interface/port to listen for RPC connections (default port: 8334, testnet: 18334)
		RPCUser              string   // Username for RPC connections
		RPCPass              string   // Password for RPC connections
		RPCLimitUser         string   //Username for limited RPC connections
		RPCLimitPass         string   //Password for limited RPC connections
		RPCCert              string   `default:""` //File containing the certificate file
		RPCKey               string   //File containing the certificate key
		RPCMaxClients        int      //Max number of RPC clients for standard connections
		RPCMaxWebsockets     int      //Max number of RPC websocket connections
		RPCMaxConcurrentReqs int      //Max number of concurrent RPC requests that may be processed concurrently
		RPCQuirks            bool     //Mirror some JSON-RPC quirks of Bitcoin Core -- NOTE: Discouraged unless interoperability issues need to be worked around
	}
	Log struct {
		Level    string   //description:"Define level of log,include trace, debug, info, warn, error"
		Module   []string // only output the specified module's log when using log.Print(...)
		FileName string   // the name of log file
	}
	Mempool struct {
		MinFeeRate           int64  //
		LimitAncestorCount   int    // Default for -limitancestorcount, max number of in-mempool ancestors
		LimitAncestorSize    int    // Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors
		LimitDescendantCount int    // Default for -limitdescendantcount, max number of in-mempool descendants
		LimitDescendantSize  int    // Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants
		MaxPoolSize          int64  `default:"300000000"` // Default for MaxPoolSize, maximum megabytes of mempool memory usage
		MaxPoolExpiry        int    `default:"336"`       // Default for -mempoolexpiry, expiration time for mempool transactions in hours
		CheckFrequency       uint64 `default:"4294967296"`
	}
	P2PNet struct {
		ListenAddrs         []string `validate:"require" default:"1234"`
		MaxPeers            int      `default:"128"`
		TargetOutbound      int      `default:"64"`
		ConnectPeersOnStart []string
		DisableBanning      bool   `default:"false"`
		BanThreshold        uint32 `default:"100"`
		TestNet             bool
		RegTest             bool `default:"false"`
		SimNet              bool
		DisableListen       bool     `default:"true"`
		BlocksOnly          bool     `default:"false"` //Do not accept transactions from remote peers.
		BanDuration         int64    `default:"86400"` // How long to ban misbehaving peers
		Proxy               string   // Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)
		UserAgentComments   []string // Comment to add to the user agent -- See BIP 14 for more information.
		DisableDNSSeed      bool     //Disable DNS seeding for peers
		DisableRPC          bool     `default:"false"`
		DisableTLS          bool     `default:"false"`
		Whitelists          []*net.IPNet
		NoOnion             bool     `default:"true"`  // Disable connecting to tor hidden services
		Upnp                bool     `default:"false"` // Use UPnP to map our listening port outside of NAT
		ExternalIPs         []string // Add an ip to the list of local addresses we claim to listen on to peers
		MaxTimeAdjustment   uint64   `default:"4200"`
	}
	AddrMgr struct {
		SimNet       bool
		ConnectPeers []string
	}
	Protocol struct {
		NoPeerBloomFilters bool `default:"true"`
		DisableCheckpoints bool `default:"true"`
	}
	Script struct {
		AcceptDataCarrier   bool `default:"true"`
		MaxDatacarrierBytes uint `default:"223"`
		IsBareMultiSigStd   bool `default:"true"`
		//use promiscuousMempoolFlags to make more or less check of script, the type of value is uint
		PromiscuousMempoolFlags string
		Par                     int `default:"32"`
	}
	TxOut struct {
		DustRelayFee int64 `default:"83"`
	}
	Chain struct {
		AssumeValid         string
		UtxoHashStartHeight int32 `default:"-1"`
		UtxoHashEndHeight   int32 `default:"-1"`
	}
	Mining struct {
		BlockMinTxFee int64  // default DefaultBlockMinTxFee
		BlockMaxSize  uint64 // default DefaultMaxGeneratedBlockSize
		Strategy      string `default:"ancestorfeerate"` // option:ancestorfee/ancestorfeerate
	}
	PProf struct {
		IP   string `default:"localhost"`
		Port string `default:"6060"`
	}
	BlockIndex struct {
		CheckBlockIndex bool
	}
	Wallet struct {
		Enable              bool `default:"false"`
		Broadcast           bool `default:"false"`
		SpendZeroConfChange bool `default:"true"`
	}
}

Configuration defines all configurations for application

func InitConfig

func InitConfig(args []string) *Configuration

InitConfig init configuration

func (Configuration) Validate

func (c Configuration) Validate() error

Validate validates configuration

type Opts

type Opts struct {
	ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`

	DataDir string `long:"datadir" description:"specified program data dir"`
	Reindex bool   `long:"reindex" description:"reindex"`

	// //Set -discover=0 in regtest framework
	// Discover int  `long:"discover" default:"1" description:"Discover own IP addresses (default: 1 when listening and no -externalip or -proxy) "`
	RegTest bool `long:"regtest" description:"initiate regtest"`
	TestNet bool `long:"testnet" description:"initiate testnet"`

	UtxoHashStartHeigh int32 `long:"utxohashstartheight" default:"-1" description:"Which height begin logging out the utxos hash at"`
	UtxoHashEndHeigh   int32 `long:"utxohashendheight" default:"-1" description:"Which height finish logging out the utxos hash at"`

	Whitelists         []string `long:"whitelist" description:"whitelist"`
	Excessiveblocksize uint64   `long:"excessiveblocksize" default:"32000000" description:"excessive block size"`
	BanScore           uint32   `long:"banscore" default:"100" description:"Threshold for disconnecting misbehaving peers"`

	ReplayProtectionActivationTime int64  `long:"replayprotectionactivationtime" default:"-1"`
	MagneticAnomalyTime            int64  `long:"magneticanomalyactivationtime" default:"-1"`
	StopAtHeight                   int32  `long:"stopatheight" default:"-1"`
	PromiscuousMempoolFlags        string `long:"promiscuousmempoolflags"`
	Limitancestorcount             int    `long:"limitancestorcount" default:"50000"`
	BlockVersion                   int32  `long:"blockversion" default:"-1" description:"regtest block version"`
	MaxMempool                     int64  `long:"maxmempool" default:"300000000"`
	SpendZeroConfChange            uint8  `long:"spendzeroconfchange" default:"1"`
	MaxTimeAdjustment              uint64 `` /* 194-byte string literal not displayed */
	MinimumChainWork               string `long:"minimumchainwork"`
	AssumeValid                    string `long:"assumevalid"`
}

func InitArgs

func InitArgs(args []string) (*Opts, error)

func (*Opts) String

func (opts *Opts) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL