aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2019-05-08 11:12:23 +0800
committerSonic <sonic@dexon.org>2019-05-08 11:12:23 +0800
commit8ddf407b731f6baf1af1275c07b6861579cbc749 (patch)
tree39792217dba89453cb70bbd159a9ef720ed6e002
parent296787fb404212631d3167406bd369cd941a81b5 (diff)
downloaddexon-8ddf407b731f6baf1af1275c07b6861579cbc749.tar
dexon-8ddf407b731f6baf1af1275c07b6861579cbc749.tar.gz
dexon-8ddf407b731f6baf1af1275c07b6861579cbc749.tar.bz2
dexon-8ddf407b731f6baf1af1275c07b6861579cbc749.tar.lz
dexon-8ddf407b731f6baf1af1275c07b6861579cbc749.tar.xz
dexon-8ddf407b731f6baf1af1275c07b6861579cbc749.tar.zst
dexon-8ddf407b731f6baf1af1275c07b6861579cbc749.zip
lds: replace eth with dex
-rw-r--r--lds/backend.go17
-rw-r--r--lds/commons.go4
-rw-r--r--lds/peer.go13
-rw-r--r--lds/server.go18
4 files changed, 27 insertions, 25 deletions
diff --git a/lds/backend.go b/lds/backend.go
index 97caca62f..e9922a496 100644
--- a/lds/backend.go
+++ b/lds/backend.go
@@ -26,11 +26,12 @@ import (
"github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/common/hexutil"
"github.com/dexon-foundation/dexon/consensus"
+ "github.com/dexon-foundation/dexon/consensus/dexcon"
"github.com/dexon-foundation/dexon/core"
"github.com/dexon-foundation/dexon/core/bloombits"
"github.com/dexon-foundation/dexon/core/rawdb"
"github.com/dexon-foundation/dexon/core/types"
- "github.com/dexon-foundation/dexon/eth"
+ "github.com/dexon-foundation/dexon/dex"
"github.com/dexon-foundation/dexon/eth/downloader"
"github.com/dexon-foundation/dexon/eth/filters"
"github.com/dexon-foundation/dexon/eth/gasprice"
@@ -42,7 +43,7 @@ import (
"github.com/dexon-foundation/dexon/p2p"
"github.com/dexon-foundation/dexon/p2p/discv5"
"github.com/dexon-foundation/dexon/params"
- rpc "github.com/dexon-foundation/dexon/rpc"
+ "github.com/dexon-foundation/dexon/rpc"
)
type LightDexon struct {
@@ -77,12 +78,12 @@ type LightDexon struct {
wg sync.WaitGroup
}
-func New(ctx *node.ServiceContext, config *eth.Config) (*LightDexon, error) {
- chainDb, err := eth.CreateDB(ctx, config, "lightchaindata")
+func New(ctx *node.ServiceContext, config *dex.Config) (*LightDexon, error) {
+ chainDb, err := dex.CreateDB(ctx, config, "lightchaindata")
if err != nil {
return nil, err
}
- chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.ConstantinopleOverride)
+ chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis)
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat {
return nil, genesisErr
}
@@ -102,11 +103,11 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightDexon, error) {
peers: peers,
reqDist: newRequestDistributor(peers, quitSync),
accountManager: ctx.AccountManager,
- engine: eth.CreateConsensusEngine(ctx, chainConfig, &config.Ethash, nil, false, chainDb),
+ engine: dexcon.New(),
shutdownChan: make(chan bool),
networkId: config.NetworkId,
bloomRequests: make(chan chan *bloombits.Retrieval),
- bloomIndexer: eth.NewBloomIndexer(chainDb, params.BloomBitsBlocksClient, params.HelperTrieConfirmations),
+ bloomIndexer: dex.NewBloomIndexer(chainDb, params.BloomBitsBlocksClient, params.HelperTrieConfirmations),
}
ldex.relay = NewLdsTxRelay(peers, ldex.reqDist)
@@ -142,7 +143,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightDexon, error) {
ldex.ApiBackend = &LdsApiBackend{ldex, nil}
gpoParams := config.GPO
if gpoParams.Default == nil {
- gpoParams.Default = config.MinerGasPrice
+ gpoParams.Default = config.DefaultGasPrice
}
ldex.ApiBackend.gpo = gasprice.NewOracle(ldex.ApiBackend, gpoParams)
return ldex, nil
diff --git a/lds/commons.go b/lds/commons.go
index 29a8f8d66..459354f6b 100644
--- a/lds/commons.go
+++ b/lds/commons.go
@@ -22,7 +22,7 @@ import (
"github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/core"
- "github.com/dexon-foundation/dexon/eth"
+ "github.com/dexon-foundation/dexon/dex"
"github.com/dexon-foundation/dexon/ethdb"
"github.com/dexon-foundation/dexon/light"
"github.com/dexon-foundation/dexon/p2p"
@@ -32,7 +32,7 @@ import (
// ldsCommons contains fields needed by both server and client.
type ldsCommons struct {
- config *eth.Config
+ config *dex.Config
iConfig *light.IndexerConfig
chainDb ethdb.Database
protocolManager *ProtocolManager
diff --git a/lds/peer.go b/lds/peer.go
index 15615ec7a..1b1eb06cc 100644
--- a/lds/peer.go
+++ b/lds/peer.go
@@ -26,7 +26,7 @@ import (
"github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/core/types"
- "github.com/dexon-foundation/dexon/eth"
+ "github.com/dexon-foundation/dexon/dex"
"github.com/dexon-foundation/dexon/lds/flowcontrol"
"github.com/dexon-foundation/dexon/light"
"github.com/dexon-foundation/dexon/p2p"
@@ -98,11 +98,12 @@ func (p *peer) queueSend(f func()) {
}
// Info gathers and returns a collection of metadata known about a peer.
-func (p *peer) Info() *eth.PeerInfo {
- return &eth.PeerInfo{
- Version: p.version,
- Difficulty: p.Td(),
- Head: fmt.Sprintf("%x", p.Head()),
+func (p *peer) Info() *dex.PeerInfo {
+ // TODO: fix this when modify peer
+ return &dex.PeerInfo{
+ Version: p.version,
+ Number: 0,
+ Head: fmt.Sprintf("%x", p.Head()),
}
}
diff --git a/lds/server.go b/lds/server.go
index 77ce4ac78..815ea6b09 100644
--- a/lds/server.go
+++ b/lds/server.go
@@ -27,7 +27,7 @@ import (
"github.com/dexon-foundation/dexon/core"
"github.com/dexon-foundation/dexon/core/rawdb"
"github.com/dexon-foundation/dexon/core/types"
- "github.com/dexon-foundation/dexon/eth"
+ "github.com/dexon-foundation/dexon/dex"
"github.com/dexon-foundation/dexon/ethdb"
"github.com/dexon-foundation/dexon/lds/flowcontrol"
"github.com/dexon-foundation/dexon/light"
@@ -49,25 +49,25 @@ type LdsServer struct {
quitSync chan struct{}
}
-func NewLdsServer(eth *eth.Ethereum, config *eth.Config) (*LdsServer, error) {
+func NewLdsServer(dex *dex.Dexon, config *dex.Config) (*LdsServer, error) {
quitSync := make(chan struct{})
- pm, err := NewProtocolManager(eth.BlockChain().Config(), light.DefaultServerIndexerConfig, false, config.NetworkId, eth.EventMux(), eth.Engine(), newPeerSet(), eth.BlockChain(), eth.TxPool(), eth.ChainDb(), nil, nil, nil, quitSync, new(sync.WaitGroup))
+ pm, err := NewProtocolManager(dex.BlockChain().Config(), light.DefaultServerIndexerConfig, false, config.NetworkId, dex.EventMux(), dex.Engine(), newPeerSet(), dex.BlockChain(), dex.TxPool(), dex.ChainDb(), nil, nil, nil, quitSync, new(sync.WaitGroup))
if err != nil {
return nil, err
}
lesTopics := make([]discv5.Topic, len(AdvertiseProtocolVersions))
for i, pv := range AdvertiseProtocolVersions {
- lesTopics[i] = lesTopic(eth.BlockChain().Genesis().Hash(), pv)
+ lesTopics[i] = lesTopic(dex.BlockChain().Genesis().Hash(), pv)
}
srv := &LdsServer{
ldsCommons: ldsCommons{
config: config,
- chainDb: eth.ChainDb(),
+ chainDb: dex.ChainDb(),
iConfig: light.DefaultServerIndexerConfig,
- chtIndexer: light.NewChtIndexer(eth.ChainDb(), nil, params.CHTFrequencyServer, params.HelperTrieProcessConfirmations),
- bloomTrieIndexer: light.NewBloomTrieIndexer(eth.ChainDb(), nil, params.BloomBitsBlocks, params.BloomTrieFrequency),
+ chtIndexer: light.NewChtIndexer(dex.ChainDb(), nil, params.CHTFrequencyServer, params.HelperTrieProcessConfirmations),
+ bloomTrieIndexer: light.NewBloomTrieIndexer(dex.ChainDb(), nil, params.BloomBitsBlocks, params.BloomTrieFrequency),
protocolManager: pm,
},
quitSync: quitSync,
@@ -95,7 +95,7 @@ func NewLdsServer(eth *eth.Ethereum, config *eth.Config) (*LdsServer, error) {
logger.Info("Loaded bloom trie", "section", bloomTrieLastSection, "head", bloomTrieSectionHead, "root", bloomTrieRoot)
}
- srv.chtIndexer.Start(eth.BlockChain())
+ srv.chtIndexer.Start(dex.BlockChain())
pm.server = srv
srv.defParams = &flowcontrol.ServerParams{
@@ -103,7 +103,7 @@ func NewLdsServer(eth *eth.Ethereum, config *eth.Config) (*LdsServer, error) {
MinRecharge: 50000,
}
srv.fcManager = flowcontrol.NewClientManager(uint64(config.LightServ), 10, 1000000000)
- srv.fcCostStats = newCostStats(eth.ChainDb())
+ srv.fcCostStats = newCostStats(dex.ChainDb())
return srv, nil
}