Commit 5a94e08f authored by 袁兴强's avatar 袁兴强

merge chain33

parents 0fbb2615 263a00cf
......@@ -26,7 +26,7 @@ build: depends
build_ci: depends ## Build the binary file for CI
@go build -v -i -o $(CLI) $(SRC_CLI)
@go build -v -o $(CLI) $(SRC_CLI)
@go build $(BUILD_FLAGS) -v -o $(APP)
@cp chain33.toml build/
@cp chain33.para.toml build/ci/paracross/
......
This diff is collapsed.
......@@ -377,6 +377,7 @@ func initEnvDpos() (queue.Queue, *blockchain.BlockChain, queue.Module, queue.Mod
var q = queue.New("channel")
q.SetConfig(chain33Cfg)
cfg := chain33Cfg.GetModuleConfig()
cfg.Log.LogFile = ""
sub := chain33Cfg.GetSubConfig()
chain := blockchain.New(chain33Cfg)
......
......@@ -559,6 +559,7 @@ func initEnvDpos1(configName string) (queue.Queue, *blockchain.BlockChain, queue
var q = queue.New("channel")
q.SetConfig(chain33Cfg)
cfg := chain33Cfg.GetModuleConfig()
cfg.Log.LogFile = ""
sub := chain33Cfg.GetSubConfig()
rpc.InitCfg(cfg.RPC)
......
......@@ -66,6 +66,7 @@ func initEnvPbft() (queue.Queue, *blockchain.BlockChain, *p2p.Manager, queue.Mod
var q = queue.New("channel")
q.SetConfig(chain33Cfg)
cfg := chain33Cfg.GetModuleConfig()
cfg.Log.LogFile = ""
sub := chain33Cfg.GetSubConfig()
chain := blockchain.New(chain33Cfg)
......
......@@ -41,7 +41,7 @@ enableTxQuickIndex=false
[p2p]
types=["dht"]
enable=true
enable=false
msgCacheSize=10240
driver="memdb"
dbPath="datadir/addrbook"
......
......@@ -260,6 +260,7 @@ func initEnvDpos() (queue.Queue, *blockchain.BlockChain, queue.Module, queue.Mod
var q = queue.New("channel")
q.SetConfig(chain33Cfg)
cfg := chain33Cfg.GetModuleConfig()
cfg.Log.LogFile = ""
sub := chain33Cfg.GetSubConfig()
chain := blockchain.New(chain33Cfg)
......
......@@ -429,6 +429,7 @@ func initEnvGuess() (queue.Queue, *blockchain.BlockChain, queue.Module, queue.Mo
var q = queue.New("channel")
q.SetConfig(chain33Cfg)
cfg := chain33Cfg.GetModuleConfig()
cfg.Log.LogFile = ""
sub := chain33Cfg.GetSubConfig()
chain := blockchain.New(chain33Cfg)
chain.SetQueueClient(q.Client())
......
......@@ -648,6 +648,7 @@ func initEnvGuess() (queue.Queue, *blockchain.BlockChain, queue.Module, queue.Mo
var q = queue.New("channel")
q.SetConfig(chain33Cfg)
cfg := chain33Cfg.GetModuleConfig()
cfg.Log.LogFile = ""
sub := chain33Cfg.GetSubConfig()
chain := blockchain.New(chain33Cfg)
chain.SetQueueClient(q.Client())
......
......@@ -4,6 +4,7 @@ package testnode
var DefaultConfig = `
Title="user.p.test."
CoinSymbol="bty"
ChainID=33
# TestNet=true
[crypto]
......
......@@ -81,6 +81,7 @@ type P2p struct {
subCfg *subConfig
mgr *p2p.Manager
subChan chan interface{}
lock sync.Mutex
}
// New produce a p2p object
......@@ -147,6 +148,8 @@ func (network *P2p) isRestart() bool {
//CloseP2P Close network client
func (network *P2p) CloseP2P() {
network.lock.Lock()
defer network.lock.Unlock()
log.Info("p2p network start shutdown")
atomic.StoreInt32(&network.closed, 1)
//等待业务协程停止
......@@ -321,6 +324,8 @@ func (network *P2p) genAirDropKeyFromWallet() error {
//ReStart p2p
func (network *P2p) ReStart() {
network.lock.Lock()
defer network.lock.Unlock()
//避免重复
if !atomic.CompareAndSwapInt32(&network.restart, 0, 1) {
return
......@@ -400,6 +405,11 @@ func (network *P2p) subP2pMsg() {
func (network *P2p) processEvent(msg *queue.Message, taskIdx int64, eventFunc p2pEventFunc) {
network.lock.Lock()
defer network.lock.Unlock()
if network.isClose() {
return
}
//检测重启标志,停止分发事件,需要等待重启
if network.isRestart() {
log.Info("wait for p2p restart....")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment