OSDN Git Service

Add doc of claim
[bytom/vapor.git] / config / config.go
index 616704b..be5dce6 100644 (file)
@@ -1,7 +1,6 @@
 package config
 
 import (
-       "math/big"
        "os"
        "os/user"
        "path/filepath"
@@ -27,6 +26,7 @@ type Config struct {
        Side      *SideChainConfig    `mapstructure:"side"`
        MainChain *MainChainRpcConfig `mapstructure:"mainchain"`
        Websocket *WebsocketConfig    `mapstructure:"ws"`
+       Consensus *ConsensusConfig    `mapstructure:"consensus"`
 }
 
 // Default configurable parameters.
@@ -40,6 +40,7 @@ func DefaultConfig() *Config {
                Side:       DefaultSideChainConfig(),
                MainChain:  DefaultMainChainRpc(),
                Websocket:  DefaultWebsocketConfig(),
+               Consensus:  DefaultConsensusCOnfig(),
        }
 }
 
@@ -86,9 +87,13 @@ type BaseConfig struct {
        // log file name
        LogFile string `mapstructure:"log_file"`
 
-       //Validate pegin proof by checking bytom transaction inclusion in mainchain.
+       // Validate pegin proof by checking bytom transaction inclusion in mainchain.
        ValidatePegin bool   `mapstructure:"validate_pegin"`
        Signer        string `mapstructure:"signer"`
+
+       ConsensusConfigFile string `mapstructure:"consensus_config_file"`
+
+       IpfsAddress string `mapstructure:"ipfs_addr"`
 }
 
 // Default configurable base parameters.
@@ -100,6 +105,7 @@ func DefaultBaseConfig() BaseConfig {
                DBBackend:         "leveldb",
                DBPath:            "data",
                KeysPath:          "keystore",
+               IpfsAddress:       "127.0.0.1:5001",
        }
 }
 
@@ -171,13 +177,27 @@ type WebsocketConfig struct {
        MaxNumConcurrentReqs int `mapstructure:"max_num_concurrent_reqs"`
 }
 
+type ConsensusConfig struct {
+       Type             string   `mapstructure:"consensus_type"`
+       Period           uint64   `json:"period"`            // Number of seconds between blocks to enforce
+       MaxSignerCount   uint64   `json:"max_signers_count"` // Max count of signers
+       MinVoterBalance  uint64   `json:"min_boter_balance"` // Min voter balance to valid this vote
+       GenesisTimestamp uint64   `json:"genesis_timestamp"` // The LoopStartTime of first Block
+       Coinbase         string   `json:"coinbase"`
+       XPrv             string   `json:"xprv"`
+       SelfVoteSigners  []string `json:"signers"` // Signers vote by themselves to seal the block, make sure the signer accounts are pre-funded
+       Signers          []common.Address
+}
+
 type DposConfig struct {
-       Period           uint64           `json:"period"`            // Number of seconds between blocks to enforce
-       Epoch            uint64           `json:"epoch"`             // Epoch length to reset votes and checkpoint
-       MaxSignerCount   uint64           `json:"max_signers_count"` // Max count of signers
-       MinVoterBalance  *big.Int         `json:"min_boter_balance"` // Min voter balance to valid this vote
-       GenesisTimestamp uint64           `json:"genesis_timestamp"` // The LoopStartTime of first Block
-       SelfVoteSigners  []common.Address `json:"signers"`           // Signers vote by themselves to seal the block, make sure the signer accounts are pre-funded
+       Period           uint64   `json:"period"`            // Number of seconds between blocks to enforce
+       MaxSignerCount   uint64   `json:"max_signers_count"` // Max count of signers
+       MinVoterBalance  uint64   `json:"min_boter_balance"` // Min voter balance to valid this vote
+       GenesisTimestamp uint64   `json:"genesis_timestamp"` // The LoopStartTime of first Block
+       Coinbase         string   `json:"coinbase"`
+       XPrv             string   `json:"xprv"`
+       SelfVoteSigners  []string `json:"signers"` // Signers vote by themselves to seal the block, make sure the signer accounts are pre-funded
+       Signers          []common.Address
 }
 
 // Default configurable rpc's auth parameters.
@@ -225,6 +245,24 @@ func DefaultWebsocketConfig() *WebsocketConfig {
        }
 }
 
+func DefaultDposConfig() *DposConfig {
+       return &DposConfig{
+               Period:           1,
+               MaxSignerCount:   1,
+               MinVoterBalance:  0,
+               GenesisTimestamp: 1524549600,
+       }
+}
+
+func DefaultConsensusCOnfig() *ConsensusConfig {
+       return &ConsensusConfig{
+               Type:             "dpos",
+               Period:           1,
+               MaxSignerCount:   1,
+               MinVoterBalance:  0,
+               GenesisTimestamp: 1524549600}
+}
+
 //-----------------------------------------------------------------------------
 // Utils