diff --git a/conf/logback.xml b/conf/logback.xml
index 8a39ce15..5c551587 100644
--- a/conf/logback.xml
+++ b/conf/logback.xml
@@ -80,6 +80,27 @@
+
+
+ logs/RepChain-Vote-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+ 30
+ 3GB
+
+
+
+ TRACE
+
+
+ false
+ false
+
+ %date{ISO8601} %-5level %logger{36} %X{akkaSource} - %msg%n
+ UTF-8
+
+
+
logs/RepChain-BlockSyncher-%d{yyyy-MM-dd}.%i.log
@@ -191,6 +212,10 @@
+
+
+
+
diff --git a/src/main/scala/rep/log/RepLogger.scala b/src/main/scala/rep/log/RepLogger.scala
index e798a7d2..58ffdb54 100644
--- a/src/main/scala/rep/log/RepLogger.scala
+++ b/src/main/scala/rep/log/RepLogger.scala
@@ -33,6 +33,7 @@ object RepLogger {
def Storager_Logger = LoggerFactory.getLogger("Storager_Logger")
def StatisTime_Logger = LoggerFactory.getLogger("StatisTime_Logger")
def Sandbox_Logger = LoggerFactory.getLogger("Sandbox_Logger")
+ def Vote_Logger = LoggerFactory.getLogger("Vote_Logger")
def trace(logger:Logger,msg:String)={
logger.trace(msg)
diff --git a/src/main/scala/rep/network/consensus/vote/CRFDVoter.scala b/src/main/scala/rep/network/consensus/vote/CRFDVoter.scala
index b5d98ac7..6c7ca933 100644
--- a/src/main/scala/rep/network/consensus/vote/CRFDVoter.scala
+++ b/src/main/scala/rep/network/consensus/vote/CRFDVoter.scala
@@ -67,7 +67,7 @@ trait CRFDVoter extends VoterBase {
randomArray
}
- override def candidators(nodes: Set[String], seed: Array[Byte]): Array[String] = {
+ override def candidators(Systemname:String,hash:String,nodes: Set[String], seed: Array[Byte]): Array[String] = {
var nodesSeq = nodes.toSeq.sortBy(f=>(f.toString()))
var len = nodes.size / 2 + 1
val min_len = 4
@@ -89,6 +89,9 @@ trait CRFDVoter extends VoterBase {
var e = randomList(j)
candidate(j) = nodesSeq(e.generateSerial)
}
+ RepLogger.debug(RepLogger.Vote_Logger, s"sysname=${Systemname},hash=${hash},hashvalue=${hashSeed},randomList=${randomList.mkString("|")}")
+ RepLogger.debug(RepLogger.Vote_Logger, s"sysname=${Systemname},candidates=${candidate.mkString("|")}")
+
candidate
}
}
diff --git a/src/main/scala/rep/network/consensus/vote/Voter.scala b/src/main/scala/rep/network/consensus/vote/Voter.scala
index 180f0a53..c6129d4c 100644
--- a/src/main/scala/rep/network/consensus/vote/Voter.scala
+++ b/src/main/scala/rep/network/consensus/vote/Voter.scala
@@ -45,7 +45,7 @@ class Voter(moduleName: String) extends ModuleBase(moduleName) with CRFDVoter {
import scala.concurrent.forkjoin.ThreadLocalRandom
override def preStart(): Unit = {
- RepLogger.info(RepLogger.Consensus_Logger, this.getLogMsgPrefix( "Vote module start"))
+ RepLogger.info(RepLogger.Vote_Logger, this.getLogMsgPrefix( "Vote module start"))
}
val dataaccess: ImpDataAccess = ImpDataAccess.GetDataAccess(pe.getSysTag)
@@ -74,11 +74,12 @@ class Voter(moduleName: String) extends ModuleBase(moduleName) with CRFDVoter {
private def resetCandidator = {
this.BlockHashOfVote = pe.getCurrentBlockHash
- val candidatorCur = candidators(SystemCertList.getSystemCertList, Sha256.hash(BlockHashOfVote))
+ val candidatorCur = candidators(pe.getSysTag,this.BlockHashOfVote,SystemCertList.getSystemCertList, Sha256.hash(BlockHashOfVote))
pe.getNodeMgr.resetCandidator(candidatorCur)
}
private def resetBlocker(idx: Int) = {
+ RepLogger.trace(RepLogger.Vote_Logger, this.getLogMsgPrefix( s"sysname=${pe.getSysTag},votelist=${pe.getNodeMgr.getCandidator.toArray[String].mkString("|")},idx=${idx}"))
this.Blocker = BlockerInfo(blocker(pe.getNodeMgr.getCandidator.toArray[String], idx), idx, System.currentTimeMillis())
pe.resetBlocker(this.Blocker)
NoticeBlockerMsg
@@ -104,26 +105,26 @@ class Voter(moduleName: String) extends ModuleBase(moduleName) with CRFDVoter {
this.cleanVoteInfo
this.resetCandidator
this.resetBlocker(0)
- RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix( s"first voter,blocker=${this.Blocker.blocker},voteidx=${this.Blocker.VoteIndex}" + "~" + selfAddr))
+ RepLogger.trace(RepLogger.Vote_Logger, this.getLogMsgPrefix( s"sysname=${pe.getSysTag},first voter,blocker=${this.Blocker.blocker},voteidx=${this.Blocker.VoteIndex}" + "~" + selfAddr))
} else {
if (!this.BlockHashOfVote.equals(pe.getCurrentBlockHash)) {
//抽签的基础块已经变化,需要重续选择候选人
this.cleanVoteInfo
this.resetCandidator
this.resetBlocker(0)
- RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix( s"hash change,reset voter,height=${pe.getCurrentHeight},blocker=${this.Blocker.blocker},voteidx=${this.Blocker.VoteIndex}" + "~" + selfAddr))
+ RepLogger.trace(RepLogger.Vote_Logger, this.getLogMsgPrefix( s"sysname=${pe.getSysTag},hash change,reset voter,height=${pe.getCurrentHeight},blocker=${this.Blocker.blocker},voteidx=${this.Blocker.VoteIndex}" + "~" + selfAddr))
} else {
if (this.Blocker.blocker == "") {
this.cleanVoteInfo
this.resetCandidator
this.resetBlocker(0)
- RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix( s"blocker=null,reset voter,height=${pe.getCurrentHeight},blocker=${this.Blocker.blocker},voteidx=${this.Blocker.VoteIndex}" + "~" + selfAddr))
+ RepLogger.trace(RepLogger.Vote_Logger, this.getLogMsgPrefix( s"sysname=${pe.getSysTag},blocker=null,reset voter,height=${pe.getCurrentHeight},blocker=${this.Blocker.blocker},voteidx=${this.Blocker.VoteIndex}" + "~" + selfAddr))
} else {
if ((System.currentTimeMillis() - this.Blocker.voteTime) / 1000 > TimePolicy.getTimeOutBlock) {
//说明出块超时
this.voteCount = 0
this.resetBlocker(this.Blocker.VoteIndex + 1)
- RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix( s"block timeout,reset voter,height=${pe.getCurrentHeight},blocker=${this.Blocker.blocker},voteidx=${this.Blocker.VoteIndex}" + "~" + selfAddr))
+ RepLogger.trace(RepLogger.Vote_Logger, this.getLogMsgPrefix( s"sysname=${pe.getSysTag},block timeout,reset voter,height=${pe.getCurrentHeight},blocker=${this.Blocker.blocker},voteidx=${this.Blocker.VoteIndex}" + "~" + selfAddr))
} else {
NoticeBlockerMsg
}
diff --git a/src/main/scala/rep/network/consensus/vote/VoterBase.scala b/src/main/scala/rep/network/consensus/vote/VoterBase.scala
index 10998540..f4e08f2b 100644
--- a/src/main/scala/rep/network/consensus/vote/VoterBase.scala
+++ b/src/main/scala/rep/network/consensus/vote/VoterBase.scala
@@ -46,5 +46,5 @@ trait VoterBase {
* @return
*/
//def candidators[T](nodes:Set[T], seed:Array[Byte]):Set[T]
- def candidators(nodes:Set[String], seed:Array[Byte]):Array[String]
+ def candidators(Systemname:String,hash:String,nodes:Set[String], seed:Array[Byte]):Array[String]
}
diff --git a/src/main/scala/rep/network/tools/NodeMgr.scala b/src/main/scala/rep/network/tools/NodeMgr.scala
index 329a03e3..68907426 100644
--- a/src/main/scala/rep/network/tools/NodeMgr.scala
+++ b/src/main/scala/rep/network/tools/NodeMgr.scala
@@ -30,7 +30,8 @@ class NodeMgr {
//本地缓存稳定的网络节点
private var stableNodes: TreeMap[Address, String] = new TreeMap[Address, String]()
//本地上次候选人名单
- private var candidator: TreeMap[String, String] = new TreeMap[String, String]()
+ //private var candidator: TreeMap[String, String] = new TreeMap[String, String]()
+ private var candidator: Set[String] = Set.empty[String]
def getNodes: Set[Address] = {
var source = Set.empty[Address]
@@ -146,14 +147,14 @@ class NodeMgr {
var source = Set.empty[String]
candidatorLock.lock()
try {
- source = candidator.values.toArray.toSet
+ source = candidator
} finally {
candidatorLock.unlock()
}
source
}
- private def putCandidator(addr: String): Unit = {
+ /*private def putCandidator(addr: String): Unit = {
candidatorLock.lock()
try {
val key = addr.toString
@@ -161,18 +162,19 @@ class NodeMgr {
} finally {
candidatorLock.unlock()
}
- }
+ }*/
def resetCandidator(nds: Array[String]): Unit = {
candidatorLock.lock()
try {
- candidator = TreeMap.empty[String, String]
+ candidator = Set.empty[String]
+ candidator = nds.toSet
} finally {
candidatorLock.unlock()
}
- nds.foreach(addr => {
+ /*nds.foreach(addr => {
putCandidator(addr)
- })
+ })*/
}
}
\ No newline at end of file