config

package
v0.0.0-...-be1c10e Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 (
	HDCoinTypeTestNet     uint32 = 1
	HDCoinTypeMassMainNet uint32 = 297
)
View Source
var ChainParams = Params{
	Name:        defaultChainTag,
	DefaultPort: "43453",
	DNSSeeds:    []string{},

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

	Checkpoints: []Checkpoint{
		{150000, newHashFromStr("b5864e69b3639fde4dbe2496c9f9f5164591917082eb95c0d99022513286b0f2")},
		{300000, newHashFromStr("ae09d31fa05a1df7eb4e81fcf14db533d64533b134f96f9afa5a2ab5cfb086c5")},
		{450000, newHashFromStr("677e150515e016e04d7fb3532a69fc99a27a74acb10819827a015a3f9fe19542")},
		{600000, newHashFromStr("bb10bd5a7ab626b61eefb387d906e76ea69fb08912fbc0cb031e489157381b81")},
		{750000, newHashFromStr("669c2fae2e772623d985f364478fff25bb4a39d9d986493d8236f01e8abab78d")},
		{900000, newHashFromStr("1b78fbfc8e7b3a0bcdd82ab16da3a5136d974bc51b108519584b08f1d879334c")},
		{1050000, newHashFromStr("8c929a910184a8558cf40a11b887582bd08e0b6a2814b291ccc891423466f9cd")},
		{1200000, newHashFromStr("965fd52574178734be81c1d75d632090e5bfa3607d35e4d27487fccff993c042")},
		{1390000, newHashFromStr("bd02ce24fa5dbf6354a19def8e1de746a832bf904e4f9421d7355d166e8acf79")},
	},

	RelayNonStdTxs: false,

	Bech32HRPSegwit: "ms",

	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: HDCoinTypeMassMainNet,
}

ChainParams defines the network parameters for the main Mass 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")
)

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 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 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 Mass 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(blk *wire.MsgBlock)

Must call this func when mock chain.

Types

type Chain

type Chain struct {
	DisableCheckpoints bool     `json:"disable_checkpoints"`
	AddCheckpoints     []string `json:"add_checkpoints"`
}

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.

func MergeCheckpoints

func MergeCheckpoints(defaultCheckpoints, additional []Checkpoint) []Checkpoint

MergeCheckpoints returns two slices of checkpoints merged into one slice such that the checkpoints are sorted by height. In the case the additional checkpoints contain a checkpoint with the same height as a checkpoint in the default checkpoints, the additional checkpoint will take precedence and overwrite the default one.

func ParseCheckpoints

func ParseCheckpoints(checkpointStrings []string) ([]Checkpoint, error)

parseCheckpoints checks the checkpoint strings for valid syntax ('<height>:<hash>') and parses them to Checkpoint instances.

type Config

type Config struct {
	Chain     *Chain     `json:"chain"`
	Metrics   *Metrics   `json:"metrics"`
	P2P       *P2P       `json:"p2p"`
	Log       *Log       `json:"log"`
	Datastore *Datastore `json:"datastore"`
}

type Datastore

type Datastore struct {
	Dir    string `json:"dir"`
	DBType string `json:"db_type"`
}

type Log

type Log struct {
	LogDir        string `json:"log_dir"`
	LogLevel      string `json:"log_level"`
	DisableCPrint bool   `json:"disable_cprint"`
}

type Metrics

type Metrics struct {
	ProfilePort string `json:"profile_port"`
}

type P2P

type P2P struct {
	Seeds                string   `json:"seeds"`
	AddPeer              []string `json:"add_peer"`
	SkipUpnp             bool     `json:"skip_upnp"`
	HandshakeTimeout     uint32   `json:"handshake_timeout"`
	DialTimeout          uint32   `json:"dial_timeout"`
	VaultMode            bool     `json:"vault_mode"`
	ListenAddress        string   `json:"listen_address"`
	Whitelist            []string `json:"whitelist"`
	IgnoreTransactionMsg bool     `json:"ignore_transaction_message"`
}

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
}

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

Jump to

Keyboard shortcuts

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