diff options
author | Wei-Ning Huang <w@cobinhood.com> | 2018-09-25 18:55:00 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:21:31 +0800 |
commit | 2ba220653fdf945844896458821808f2edd8f4af (patch) | |
tree | 5fb24eed28de25b59e12c7472a222f2a338e2f53 /dex | |
parent | 94bb940818d9b5c6d654da14f13918e65cf84623 (diff) | |
download | go-tangerine-2ba220653fdf945844896458821808f2edd8f4af.tar go-tangerine-2ba220653fdf945844896458821808f2edd8f4af.tar.gz go-tangerine-2ba220653fdf945844896458821808f2edd8f4af.tar.bz2 go-tangerine-2ba220653fdf945844896458821808f2edd8f4af.tar.lz go-tangerine-2ba220653fdf945844896458821808f2edd8f4af.tar.xz go-tangerine-2ba220653fdf945844896458821808f2edd8f4af.tar.zst go-tangerine-2ba220653fdf945844896458821808f2edd8f4af.zip |
Use dex.Config instead of eth.Config
Diffstat (limited to 'dex')
-rw-r--r-- | dex/app.go | 26 | ||||
-rw-r--r-- | dex/backend.go | 16 | ||||
-rw-r--r-- | dex/config.go | 45 | ||||
-rw-r--r-- | dex/governance.go | 3 |
4 files changed, 18 insertions, 72 deletions
diff --git a/dex/app.go b/dex/app.go index f87f669fb..21857f3c6 100644 --- a/dex/app.go +++ b/dex/app.go @@ -18,9 +18,6 @@ package dex import ( - "time" - - "github.com/dexon-foundation/dexon-consensus-core/common" "github.com/dexon-foundation/dexon-consensus-core/core/types" "github.com/ethereum/go-ethereum/core" @@ -45,26 +42,13 @@ func (d *DexconApp) PreparePayload(position types.Position) []byte { return nil } -// VerifyPayloads verifies if the payloads are valid. -func (d *DexconApp) VerifyPayloads(payloads []byte) bool { +// VerifyPayload verifies if the payloads are valid. +func (d *DexconApp) VerifyPayload(payload []byte) bool { return true } -// BlockConfirmed is called when a block is confirmed and added to lattice. -func (d *DexconApp) BlockConfirmed(block *types.Block) { -} - -// StronglyAcked is called when a block is strongly acked. -func (d *DexconApp) StronglyAcked(blockHash common.Hash) { -} - -// TotalOrderingDeliver is called when the total ordering algorithm deliver -// a set of block. -func (d *DexconApp) TotalOrderingDeliver(blockHashes common.Hashes, early bool) { -} - -// DeliverBlock is called when a block is add to the compaction chain. -func (d *DexconApp) DeliverBlock(blockHash common.Hash, timestamp time.Time) { +// BlockDelivered is called when a block is add to the compaction chain. +func (d *DexconApp) BlockDelivered(block types.Block) { } // BlockProcessedChan returns a channel to receive the block hashes that have @@ -74,5 +58,5 @@ func (d *DexconApp) BlockProcessedChan() <-chan types.WitnessResult { } // WitnessAckDeliver is called when a notary ack is created. -func (d *DexconApp) WitnessAckDeliver(notaryAck *types.WitnessAck) { +func (d *DexconApp) WitnessAckDelivered(notaryAck *types.WitnessAck) { } diff --git a/dex/backend.go b/dex/backend.go index c313f590b..1da083984 100644 --- a/dex/backend.go +++ b/dex/backend.go @@ -18,20 +18,15 @@ package dex import ( - "math/big" - "sync" - dexCore "github.com/dexon-foundation/dexon-consensus-core/core" "github.com/dexon-foundation/dexon-consensus-core/core/blockdb" ethCrypto "github.com/dexon-foundation/dexon-consensus-core/crypto/eth" "github.com/dexon-foundation/dexon/internal/ethapi" "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/bloombits" - "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/node" @@ -42,7 +37,7 @@ import ( // Dexon implementes the DEXON fullnode service. type Dexon struct { - config *eth.Config + config *Config chainConfig *params.ChainConfig // Channel for shutting down the service @@ -60,9 +55,6 @@ type Dexon struct { bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests bloomIndexer *core.ChainIndexer // Bloom indexer operating during block imports - gasPrice *big.Int - etherbase common.Address - // Dexon consensus. app *DexconApp governance *DexconGovernance @@ -72,11 +64,9 @@ type Dexon struct { networkID uint64 netRPCService *ethapi.PublicNetAPI - - lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase) } -func New(ctx *node.ServiceContext, config *eth.Config) (*Dexon, error) { +func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) { // Consensus. db, err := blockdb.NewLevelDBBackedBlockDB("main.blockdb") if err != nil { @@ -100,8 +90,6 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*Dexon, error) { accountManager: ctx.AccountManager, shutdownChan: make(chan bool), networkID: config.NetworkId, - gasPrice: config.MinerGasPrice, - etherbase: config.Etherbase, bloomRequests: make(chan chan *bloombits.Retrieval), app: app, governance: gov, diff --git a/dex/config.go b/dex/config.go index 629e29120..d383c17df 100644 --- a/dex/config.go +++ b/dex/config.go @@ -17,42 +17,28 @@ package dex import ( - "math/big" "os" "os/user" "path/filepath" "runtime" "time" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/consensus/ethash" + "github.com/ethereum/go-ethereum/consensus/dexcon" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/gasprice" - "github.com/ethereum/go-ethereum/params" ) // DefaultConfig contains default settings for use on the Ethereum main net. var DefaultConfig = Config{ - SyncMode: downloader.FastSync, - Ethash: ethash.Config{ - CacheDir: "ethash", - CachesInMem: 2, - CachesOnDisk: 3, - DatasetsInMem: 1, - DatasetsOnDisk: 2, - }, + SyncMode: downloader.FastSync, + Dexcon: dexcon.Config{}, NetworkId: 1, LightPeers: 100, DatabaseCache: 768, TrieCleanCache: 256, TrieDirtyCache: 256, TrieTimeout: 60 * time.Minute, - MinerGasFloor: 8000000, - MinerGasCeil: 8000000, - MinerGasPrice: big.NewInt(params.GWei), - MinerRecommit: 3 * time.Second, TxPool: core.DefaultTxPoolConfig, GPO: gasprice.Config{ @@ -69,13 +55,13 @@ func init() { } } if runtime.GOOS == "windows" { - DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Ethash") + DefaultConfig.DatabaseDir = filepath.Join(home, "AppData", "Dexcon") } else { - DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash") + DefaultConfig.DatabaseDir = filepath.Join(home, ".dexcon") } } -//go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go +//go:generate gencodec -type Config -formats toml -out gen_config.go type Config struct { // The genesis block, which is inserted if the database is empty. @@ -95,22 +81,13 @@ type Config struct { SkipBcVersionCheck bool `toml:"-"` DatabaseHandles int `toml:"-"` DatabaseCache int + DatabaseDir string TrieCleanCache int TrieDirtyCache int TrieTimeout time.Duration - // Mining-related options - Etherbase common.Address `toml:",omitempty"` - MinerNotify []string `toml:",omitempty"` - MinerExtraData []byte `toml:",omitempty"` - MinerGasFloor uint64 - MinerGasCeil uint64 - MinerGasPrice *big.Int - MinerRecommit time.Duration - MinerNoverify bool - - // Ethash options - Ethash ethash.Config + // Dexcon options + Dexcon dexcon.Config // Transaction pool options TxPool core.TxPoolConfig @@ -129,7 +106,3 @@ type Config struct { // Type of the EVM interpreter ("" for default) EVMInterpreter string } - -type configMarshaling struct { - MinerExtraData hexutil.Bytes -} diff --git a/dex/governance.go b/dex/governance.go index 0ef0b56db..fd52a8697 100644 --- a/dex/governance.go +++ b/dex/governance.go @@ -14,7 +14,8 @@ func NewDexconGovernance() *DexconGovernance { } // GetValidatorSet returns the current notary set. -func (d *DexconGovernance) GetNotarySet() map[types.NodeID]struct{} { +func (d *DexconGovernance) GetNotarySet( + blockHeight uint64) map[types.NodeID]struct{} { return make(map[types.NodeID]struct{}) } |