Ejemplo n.º 1
0
        public override void Awake(JToken jd = null)
        {
            ComponentNetMsg componentNetMsg = Entity.Root.GetComponent <ComponentNetMsg>();

            //componentNetMsg.registerMsg(NetOpcode.A2M_HearBeat, A2M_HearBeat_Handle);
            componentNetMsg.registerMsg(NetOpcode.Q2P_New_Node, Q2P_New_Node_Handle);
            //componentNetMsg.registerMsg(NetOpcode.R2P_New_Node, R2P_New_Node_Handle);
        }
Ejemplo n.º 2
0
        public override void Awake(JToken jd = null)
        {
            ComponentNetMsg componentNetMsg = Entity.Root.GetComponent <ComponentNetMsg>();

            //componentNetMsg.registerMsg(NetOpcode.A2M_HearBeat, A2M_HearBeat_Handle);
            componentNetMsg.registerMsg(NetOpcode.Q2P_New_Node, Q2P_New_Node_Handle);
            //componentNetMsg.registerMsg(NetOpcode.R2P_New_Node, R2P_New_Node_Handle);

            // 是否添加自身到Nodes列表
            bool bRun = true;

            if (jd["AddSelfToNodes"] != null)
            {
                bool.TryParse(jd["AddSelfToNodes"].ToString(), out bRun);
            }
            Run(bRun);
        }
Ejemplo n.º 3
0
        public override void Start()
        {
            rule = Entity.Root.GetComponent <Rule>();
            ComponentNetMsg componentNetMsg = Entity.Root.GetComponent <ComponentNetMsg>();

            componentNetMsg.registerMsg(NetOpcode.P2P_NewBlock, P2P_NewBlock_Handle);

            string genesisText = File.ReadAllText("./Data/genesisBlock.dat");
            Block  blk         = JsonHelper.FromJson <Block>(genesisText);

            superAddress = blk.Address;

            long.TryParse(Entity.Root.GetComponent <LevelDBStore>().Get("UndoHeight"), out long UndoHeight);
            if (UndoHeight == 0)
            {
                if (true)
                {
                    blockMgr.AddBlock(blk);
                    ApplyGenesis(blk);
                }
            }

            string consData = Base58.Encode(FileHelper.GetFileData("./Data/Contract/RuleContract_v1.0.lua").ToByteArray());

            consAddress = Wallet.ToAddress(CryptoHelper.Sha256(Encoding.UTF8.GetBytes(consData)));

            using (DbSnapshot snapshot = levelDBStore.GetSnapshot())
            {
                LuaVMScript luaVMScript = new LuaVMScript()
                {
                    script = FileHelper.GetFileData("./Data/Contract/RuleContract_curr.lua").ToByteArray()
                };
                snapshot.Contracts.Add(consAddress, luaVMScript);
                snapshot.Commit();
            }
            ruleInfos = luaVMEnv.GetRules(consAddress, UndoHeight);

            if (bRun)
            {
                Run();
            }
        }
Ejemplo n.º 4
0
        public override void Awake(JToken jd = null)
        {
            if (jd["minerLimit"] != null)
            {
                int.TryParse(jd["minerLimit"]?.ToString(), out minerLimit);
            }
            if (jd["ignorePower"] != null)
            {
                double.TryParse(jd["ignorePower"]?.ToString(), out ignorePower);
            }

            poolPassword = jd["poolPassword"]?.ToString();

            Log.Info($"HttpPool.minerLimit   = {minerLimit}");
            Log.Info($"HttpPool.ignorePower  = {ignorePower}");

            ComponentNetMsg componentNetMsg = Entity.Root.GetComponent <ComponentNetMsg>();

            componentNetMsg.registerMsg(NetOpcodeBase.HttpMessage, OnHttpMessage);
        }
Ejemplo n.º 5
0
        public override void Awake(JToken jd = null)
        {
            ComponentNetMsg componentNetMsg = Entity.Root.GetComponent <ComponentNetMsg>();

            componentNetMsg.registerMsg(NetOpcodeBase.HttpMessage, OnHttpMessage);
        }
Ejemplo n.º 6
0
        public override void Start()
        {
            ComponentNetMsg componentNetMsg = Entity.Root.GetComponent <ComponentNetMsg>();

            componentNetMsg.registerMsg(NetOpcode.P2P_NewBlock, P2P_NewBlock_Handle);
        }
Ejemplo n.º 7
0
        public override void Awake(JToken jd = null)
        {
            ComponentNetMsg componentNetMsg = Entity.Root.GetComponent <ComponentNetMsg>(); // 一级网络

            componentNetMsg.registerMsg(NetOpcode.P2P_NewBlock, P2P_NewBlock_Handle);
        }