"github.com/bytom/bytom/env"
"github.com/bytom/bytom/event"
bytomLog "github.com/bytom/bytom/log"
- "github.com/bytom/bytom/mining/cpuminer"
- "github.com/bytom/bytom/mining/miningpool"
- "github.com/bytom/bytom/mining/tensority"
+
"github.com/bytom/bytom/net/websocket"
"github.com/bytom/bytom/netsync"
- "github.com/bytom/bytom/p2p"
"github.com/bytom/bytom/protocol"
w "github.com/bytom/bytom/wallet"
)
api *api.API
chain *protocol.Chain
txfeed *txfeed.Tracker
- cpuMiner *cpuminer.CPUMiner
- miningPool *miningpool.MiningPool
- miningEnable bool
}
// NewNode create bytom node
}
}
- syncManager, err := netsync.NewSyncManager(config, chain, txPool, dispatcher)
+ fastSyncDB := dbm.NewDB("fastsync", config.DBBackend, config.DBDir())
+ syncManager, err := netsync.NewSyncManager(config, chain, txPool, dispatcher, fastSyncDB)
if err != nil {
cmn.Exit(cmn.Fmt("Failed to create sync manager: %v", err))
}
wallet: wallet,
chain: chain,
txfeed: txFeed,
- miningEnable: config.Mining,
notificationMgr: notificationMgr,
}
- node.cpuMiner = cpuminer.NewCPUMiner(chain, accounts, txPool, dispatcher)
- node.miningPool = miningpool.NewMiningPool(chain, accounts, txPool, dispatcher)
-
node.BaseService = *cmn.NewBaseService(nil, "Node", node)
- if config.Simd.Enable {
- tensority.UseSIMD = true
- }
-
return node
}
}
func (n *Node) initAndstartAPIServer() {
- n.api = api.NewAPI(n.syncManager, n.wallet, n.txfeed, n.cpuMiner, n.miningPool, n.chain, n.config, n.accessTokens, n.eventDispatcher, n.notificationMgr)
+ n.api = api.NewAPI(n.syncManager, n.wallet, n.txfeed, n.chain, n.config, n.accessTokens, n.eventDispatcher, n.notificationMgr)
listenAddr := env.String("LISTEN", n.config.ApiAddress)
env.Parse()
}
func (n *Node) OnStart() error {
- if n.miningEnable {
- if _, err := n.wallet.AccountMgr.GetMiningAddress(); err != nil {
- n.miningEnable = false
- log.Error(err)
- } else {
- n.cpuMiner.Start()
- }
- }
if !n.config.VaultMode {
if err := n.syncManager.Start(); err != nil {
return err
n.notificationMgr.Shutdown()
n.notificationMgr.WaitForShutdown()
n.BaseService.OnStop()
- if n.miningEnable {
- n.cpuMiner.Stop()
- }
if !n.config.VaultMode {
n.syncManager.Stop()
}
n.Stop()
})
}
-
-func (n *Node) NodeInfo() *p2p.NodeInfo {
- return n.syncManager.NodeInfo()
-}
-
-func (n *Node) MiningPool() *miningpool.MiningPool {
- return n.miningPool
-}