mirror of
https://gitee.com/BTAJL/repchain.git
synced 2024-12-05 21:28:05 +08:00
重构提交8
This commit is contained in:
parent
b1e8bb7ec4
commit
061865d8c6
@ -16,10 +16,10 @@
|
||||
|
||||
package rep.network.module
|
||||
|
||||
import akka.actor.{ActorRef, Props}
|
||||
import com.typesafe.config.{Config}
|
||||
import akka.actor.{ ActorRef, Props }
|
||||
import com.typesafe.config.{ Config }
|
||||
import rep.app.conf.SystemProfile.Trans_Create_Type_Enum
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.cache.TransactionPool
|
||||
@ -27,9 +27,9 @@ import rep.network.persistence.Storager
|
||||
import rep.network.tools.Statistic.StatisticCollection
|
||||
import rep.ui.web.EventServer
|
||||
import rep.network.cluster.MemberListener
|
||||
import rep.network.sync.{SynchronizeResponser,SynchronizeRequester}
|
||||
import rep.network.sync.{ SynchronizeResponser, SynchronizeRequester }
|
||||
|
||||
import rep.network.consensus.block.{GenesisBlocker,ConfirmOfBlock,EndorseCollector,Blocker}
|
||||
import rep.network.consensus.block.{ GenesisBlocker, ConfirmOfBlock, EndorseCollector, Blocker }
|
||||
import rep.network.consensus.endorse.Endorser
|
||||
import rep.network.consensus.transaction.PreloaderForTransaction
|
||||
import rep.network.consensus.vote.Voter
|
||||
@ -45,17 +45,16 @@ import rep.crypto.cert.SignTool
|
||||
* Created by shidianyue on 2017/9/22.
|
||||
*/
|
||||
object ModuleManager {
|
||||
def props(name: String, sysTag: String,enableStatistic:Boolean,enableWebSocket:Boolean,isStartup:Boolean): Props = Props(classOf[ ModuleManager ], name, sysTag,enableStatistic:Boolean,enableWebSocket:Boolean,isStartup:Boolean)
|
||||
def props(name: String, sysTag: String, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean): Props = Props(classOf[ModuleManager], name, sysTag, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean)
|
||||
}
|
||||
|
||||
class ModuleManager(moduleName: String, sysTag: String,enableStatistic:Boolean,enableWebSocket:Boolean,isStartup:Boolean) extends ModuleBase(moduleName) {
|
||||
class ModuleManager(moduleName: String, sysTag: String, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean) extends ModuleBase(moduleName) {
|
||||
|
||||
private val conf = context.system.settings.config
|
||||
|
||||
init()
|
||||
loadModule
|
||||
|
||||
|
||||
def init(): Unit = {
|
||||
val (ip, port) = ActorUtils.getIpAndPort(selfAddr)
|
||||
pe.setIpAndPort(ip, port)
|
||||
@ -64,62 +63,58 @@ class ModuleManager(moduleName: String, sysTag: String,enableStatistic:Boolean,e
|
||||
confHeler.init()
|
||||
}
|
||||
|
||||
|
||||
|
||||
def loadModule = {
|
||||
loadClusterModule
|
||||
loadApiModule
|
||||
loadSystemModule
|
||||
loadConsensusModule
|
||||
|
||||
if(isStartup){
|
||||
if (isStartup) {
|
||||
pe.getActorRef(ActorType.voter) ! Voter.VoteOfBlocker
|
||||
}
|
||||
|
||||
logMsg(LogType.INFO, moduleName+"~"+ s"ModuleManager ${sysTag} start")
|
||||
logMsg(LogType.INFO, moduleName + "~" + s"ModuleManager ${sysTag} start")
|
||||
}
|
||||
|
||||
def loadConsensusModule={
|
||||
def loadConsensusModule = {
|
||||
val typeConsensus = context.system.settings.config.getString("system.consensus.type")
|
||||
if(typeConsensus == "CRFD"){
|
||||
if (typeConsensus == "CRFD") {
|
||||
context.actorOf(Blocker.props("blocker"), "blocker")
|
||||
context.actorOf(GenesisBlocker.props("gensisblock"), "gensisblock")
|
||||
context.actorOf(ConfirmOfBlock.props("confirmerofblock"), "confirmerofblock")
|
||||
context.actorOf(EndorseCollector.props("endorsementcollectioner"), "endorsementcollectioner")
|
||||
context.actorOf(Endorser.props("endorser"), "endorser")
|
||||
context.actorOf(PreloaderForTransaction.props("preloaderoftransaction",context.actorOf(TransProcessor.props("sandbox", "", self),"sandboxProcessor")),"preloaderoftransaction")
|
||||
context.actorOf(Endorser.props("endorser"), "endorser")
|
||||
context.actorOf(PreloaderForTransaction.props("preloaderoftransaction", context.actorOf(TransProcessor.props("sandbox", "", self), "sandboxProcessor")), "preloaderoftransaction")
|
||||
//context.actorOf(Endorser.props("endorser"), "endorser")
|
||||
context.actorOf(Voter.props("voter"), "voter")
|
||||
}
|
||||
}
|
||||
|
||||
def loadApiModule={
|
||||
if(enableStatistic) context.actorOf(Props[StatisticCollection],"statistic")
|
||||
if (enableWebSocket) context.actorOf(Props[ EventServer ], "webapi")
|
||||
def loadApiModule = {
|
||||
if (enableStatistic) context.actorOf(Props[StatisticCollection], "statistic")
|
||||
if (enableWebSocket) context.actorOf(Props[EventServer], "webapi")
|
||||
}
|
||||
|
||||
def loadSystemModule={
|
||||
def loadSystemModule = {
|
||||
context.actorOf(Storager.props("storager"), "storager")
|
||||
context.actorOf(SynchronizeRequester.props("synchrequester"), "synchrequester")
|
||||
context.actorOf(SynchronizeResponser.props("synchresponser"), "synchresponser")
|
||||
context.actorOf(TransactionPool.props("transactionpool"), "transactionpool")
|
||||
if(SystemProfile.getTransCreateType==Trans_Create_Type_Enum.AUTO){
|
||||
if (SystemProfile.getTransCreateType == Trans_Create_Type_Enum.AUTO) {
|
||||
context.actorOf(PeerHelper.props("peerhelper"), "peerhelper")
|
||||
}
|
||||
}
|
||||
|
||||
def loadClusterModule={
|
||||
context.actorOf( MemberListener.props("memberlistener"), "memberlistener")
|
||||
def loadClusterModule = {
|
||||
context.actorOf(MemberListener.props("memberlistener"), "memberlistener")
|
||||
}
|
||||
|
||||
|
||||
//除了广播消息,P2P的跨域消息都通过其中转(同步,存储等)
|
||||
override def receive: Receive = {
|
||||
case _ => //ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ConfigerHelper(conf: Config, tag: String, dbTag: String) {
|
||||
|
||||
def init(): Unit = {
|
||||
|
@ -73,12 +73,12 @@ object GlobalUtils {
|
||||
val synchrequester = 9
|
||||
val transactionpool = 10
|
||||
val storager = 11
|
||||
val synchresponser = 12
|
||||
val statiscollecter = 13
|
||||
val endorsementcollectioner = 14
|
||||
val endorsementrequester = 15
|
||||
val confirmerofblock = 16
|
||||
val gensisblock = 17
|
||||
val synchresponser = 18
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user