config

package
v0.0.0-...-163fc3c Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigFilename = "config.json"

	DefaultDataDirname = "chain"
	DefaultLogLevel    = "info"

	DefaultLoggingFilename = "skt"

	MaxMiningPayoutAddresses = 6000
)
View Source
const ChainGenesisDocHash = "73756b686176617469b34ea2f85159fa271423fcc27496b5e2"

Variables

View Source
var (
	FreeTxRelayLimit         = 15.0
	AddrIndex                = true
	NoRelayPriority          = true
	BlockPrioritySize uint32 = defaultBlockPrioritySize
	BlockMinSize      uint32 = defaultBlockMinSize
	BlockMaxSize      uint32 = defaultBlockMaxSize
	MaxPeers                 = 50
	Moniker                  = "anonymous"
	ChainTag                 = defaultChainTag
)
View Source
var (
	AppHomeDir = AppDataDir("skt", false)

	HDCoinTypeMainNet uint32 = 2021
)
View Source
var ChainParams = Params{
	Name:        defaultChainTag,
	DefaultPort: "43458",
	DNSSeeds:    []string{},

	GenesisBlock:           &genesisBlock,
	ChainID:                &genesisChainID,
	PocLimit:               mainPocLimit,
	SubsidyHalvingInterval: consensus.SubsidyHalvingInterval,
	ResetMinDifficulty:     false,

	Checkpoints: []Checkpoint{},

	RelayNonStdTxs: false,

	Bech32HRPSegwit: "sk",

	PubKeyHashAddrID:        0x00,
	ScriptHashAddrID:        0x05,
	PrivateKeyID:            0x80,
	WitnessPubKeyHashAddrID: 0x06,
	WitnessScriptHashAddrID: 0x0A,

	HDPrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4},
	HDPublicKeyID:  [4]byte{0x04, 0x88, 0xb2, 0x1e},

	HDCoinType:            HDCoinTypeMainNet,
	CompatibleHDCoinTypes: []uint32{297},
}

ChainParams defines the network parameters for the main skt network.

View Source
var (
	// ErrUnknownHDKeyID describes an error where the provided id which
	// is intended to identify the network for a hierarchical deterministic
	// private extended key is not registered.
	ErrUnknownHDKeyID = errors.New("unknown hd private extended key bytes")
)
View Source
var RunServiceCommand func(string) error

RunServiceCommand is only set to a real function on Windows. It is used to parse and execute service commands specified via the -s flag.

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 DecodeProofList

func DecodeProofList(proofList string) (map[int]int, error)

DecodeProofList decodes config proof list in format like this: "<BL>:<Count>,<BL>:<Count>". Example: 3 spaces of BL = 24, 4 spaces of BL= 26, 5 spaces of BL = 28 would be like "24:3, 26:4, 28:5". Duplicate BL would be added together, "24:1, 24:2, 26:5" equals to "24:3, 26:5".

func HDPrivateKeyToPublicKeyID

func HDPrivateKeyToPublicKeyID(id []byte) ([]byte, error)

HDPrivateKeyToPublicKeyID accepts a private hierarchical deterministic extended key id and returns the associated public key id. When the provided id is not registered, the ErrUnknownHDKeyID error will be returned.

func InitChainGenesisDoc

func InitChainGenesisDoc()

func IsBech32SegwitPrefix

func IsBech32SegwitPrefix(prefix string) bool

IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit addresses on any default or registered network. This is used when decoding an wallet string into a specific wallet type.

func IsPubKeyHashAddrID

func IsPubKeyHashAddrID(id byte) bool

IsPubKeyHashAddrID returns whether the id is an identifier known to prefix a pay-to-pubkey-hash address on any default or registered network. This is used when decoding an wallet string into a specific wallet type. It is up to the caller to check both this and IsScriptHashAddrID and decide whether an wallet is a pubkey hash wallet, script hash wallet, neither, or undeterminable (if both return true).

func IsScriptHashAddrID

func IsScriptHashAddrID(id byte) bool

IsScriptHashAddrID returns whether the id is an identifier known to prefix a pay-to-script-hash address on any default or registered network. This is used when decoding an wallet string into a specific wallet type. It is up to the caller to check both this and IsPubKeyHashAddrID and decide whether an wallet is a pubkey hash wallet, script hash wallet, neither, or undeterminable (if both return true).

func NormalizeAddress

func NormalizeAddress(addr, defaultPort string) string

NormalizeAddress returns addr with the passed default port appended if there is not already a port specified.

func NormalizeAddresses

func NormalizeAddresses(addrs []string, defaultPort string) []string

normalizeAddresses returns a new slice with all the passed peer addresses normalized with the given default port, and all duplicates removed.

func NormalizeSeed

func NormalizeSeed(seed, defaultPort string) (string, error)

NormalizeSeed accepts four types of params:

(1) [IPV4/IPV6]
(2) [IPV4/IPV6]:[PORT]
(3) [DOMAIN]
(4) [DOMAIN]:[PORT]

It returns error if receive other types of params.

Run step:

(1) check if Seed has port, then split Host and Port;
(2) check validity of Port, then assign default value to empty Port;
(3) randomly select an IP if Host is a domain;
(4) join host and port.

func NormalizeSeeds

func NormalizeSeeds(inputs, defaultPort string) string

Normalize Seeds joined with ','.

func Register

func Register(params *Params) error

Register registers the network parameters for a Skt network. This may error with ErrDuplicateNet if the network is already registered (either due to a previous Register call, or the network being one of the default networks).

Network parameters should be registered into this package by a main package as early as possible. Then, library packages may lookup networks or network parameters based on inputs and work regardless of the network being standard or not.

func UpdateGenesisBlock

func UpdateGenesisBlock(block *wire.MsgBlock)

Must call this func when mock chain.

Types

type Checkpoint

type Checkpoint struct {
	Height uint64
	Hash   *wire.Hash
}

Checkpoint identifies a known good point in the block chain. Using checkpoints allows a few optimizations for old blocks during initial download and also prevents forks from old blocks.

Each checkpoint is selected based upon several factors. See the documentation for blockchain.IsCheckpointCandidate for details on the selection criteria.

type Config

type Config struct {
	*configpb.Config
	ConfigFile  string `short:"C" long:"configfile" description:"Path to configuration file"`
	ShowVersion bool   `short:"V" long:"version" description:"Display Version information and exit"`
	Generate    bool   `long:"generate" description:"Generate (mine) coins when start"`
	Init        bool   `long:"init" description:"Init miner keystore"`
	PrivatePass string `short:"P" long:"privpass" description:"Private passphrase for miner"`
}

func CheckConfig

func CheckConfig(cfg *Config) (*Config, error)

func LoadConfig

func LoadConfig(cfg *Config) (*Config, error)

func ParseConfig

func ParseConfig() (*Config, []string, error)

ParseConfig reads and parses the config using a Config file and command line options. This func proceeds as follows:

  1. Start with a default config with sane settings
  2. Pre-parse the command line to check for an alternative config file

type GenesisAlloc

type GenesisAlloc struct {
	Value   uint64 `json:"value"`
	Address string `json:"address"`
}

type GenesisDoc

type GenesisDoc struct {
	Version    uint64           `json: "version"`
	InitHeight uint64           `json:"init_height"`
	Timestamp  uint64           `json:"timestamp"`
	Target     string           `json:"target"`
	Challenge  string           `json:"challenge"`
	PublicKey  string           `json:"public_key"`
	Proof      GenesisProof     `json:"proof"`
	Signature  GenesisSignature `json:"signature"`

	AllocTxOut []*wire.TxOut
	// contains filtered or unexported fields
}

GenesisDoc defines the initial conditions for a sukhavati blockchain, in particular its validator set.

var ChainGenesisDoc GenesisDoc

func (GenesisDoc) IsHashEqual

func (genDoc GenesisDoc) IsHashEqual(sha string) bool

func (GenesisDoc) SaveAs

func (genDoc GenesisDoc) SaveAs(file string) error

SaveAs is a utility method for saving GenesisDoc as a JSON file.

type GenesisProof

type GenesisProof struct {
	BitLength int `json:"bit_length"`
	// contains filtered or unexported fields
}

type GenesisSignature

type GenesisSignature struct {
	// contains filtered or unexported fields
}

type Params

type Params struct {
	Name        string
	DefaultPort string
	DNSSeeds    []string

	// Chain parameters
	GenesisBlock           *wire.MsgBlock
	GenesisHash            *wire.Hash
	ChainID                *wire.Hash
	PocLimit               *big.Int
	SubsidyHalvingInterval uint64
	ResetMinDifficulty     bool

	// Checkpoints ordered from oldest to newest.
	Checkpoints []Checkpoint

	// Mempool parameters
	RelayNonStdTxs bool

	// Human-readable part for Bech32 encoded segwit addresses, as defined
	// in BIP 173.
	Bech32HRPSegwit string

	// Address encoding magics
	PubKeyHashAddrID        byte // First byte of a P2PKH address
	ScriptHashAddrID        byte // First byte of a P2SH address
	PrivateKeyID            byte // First byte of a WIF private key
	WitnessPubKeyHashAddrID byte // First byte of a P2WPKH address
	WitnessScriptHashAddrID byte // First byte of a P2WSH address

	// BIP32 hierarchical deterministic extended key magics
	HDPrivateKeyID [4]byte
	HDPublicKeyID  [4]byte

	// BIP44 coin type used in the hierarchical deterministic path for
	// address generation.
	HDCoinType uint32
	// compatible hd cointype for mine
	CompatibleHDCoinTypes []uint32
}

Params defines a chain network by its parameters. These parameters may be used by skt applications to differentiate networks as well as addresses and keys for one network from those intended for use on another network.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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