Exemple #1
0
        /*
         * public void StartConsensus(Wallet wallet, Store consensus_store = null, bool ignoreRecoveryLogs = false)
         * {
         *  Consensus = ActorSystem.ActorOf(ConsensusService.Props(this.LocalNode, this.TaskManager, consensus_store ?? store, wallet));
         *  Consensus.Tell(new ConsensusService.Start { IgnoreRecoveryLogs = ignoreRecoveryLogs }, Blockchain);
         * }
         */

        /// <summary>
        /// By BHP
        /// </summary>
        /// <param name="wallet"></param>
        public void StartConsensus(Wallet wallet, Store consensus_store = null, bool ignoreRecoveryLogs = false)
        {
            bool found = false;

            foreach (WalletAccount account in wallet.GetAccounts())
            {
                string publicKey = account.GetKey().PublicKey.EncodePoint(true).ToHexString();
                foreach (ECPoint point in Ledger.Blockchain.StandbyValidators)
                {
                    string validator = point.EncodePoint(true).ToHexString();
                    if (validator.Equals(publicKey))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
            }
            //只有共识节点才能开启共识
            if (found)
            {
                Consensus = ActorSystem.ActorOf(ConsensusService.Props(this.LocalNode, this.TaskManager, consensus_store ?? store, wallet));
                Consensus.Tell(new ConsensusService.Start {
                    IgnoreRecoveryLogs = ignoreRecoveryLogs
                }, Blockchain);
            }
        }
Exemple #2
0
 public void StartConsensus(Wallet wallet, Store consensus_store = null, bool ignoreRecoveryLogs = false)
 {
     Consensus = ActorSystem.ActorOf(ConsensusService.Props(this.LocalNode, this.TaskManager, consensus_store ?? store, wallet));
     Consensus.Tell(new ConsensusService.Start {
         IgnoreRecoveryLogs = ignoreRecoveryLogs
     }, Blockchain);
 }
Exemple #3
0
        /*
         * public void StartConsensus(Wallet wallet)
         * {
         *  Consensus = ActorSystem.ActorOf(ConsensusService.Props(this.LocalNode, this.TaskManager, wallet));
         *  Consensus.Tell(new ConsensusService.Start());
         * }
         */

        /// <summary>
        /// By BHP
        /// </summary>
        /// <param name="wallet"></param>
        public void StartConsensus(Wallet wallet)
        {
            bool found = false;

            foreach (WalletAccount account in wallet.GetAccounts())
            {
                string publicKey = account.GetKey().PublicKey.EncodePoint(true).ToHexString();
                foreach (ECPoint point in Ledger.Blockchain.StandbyValidators)
                {
                    string validator = point.EncodePoint(true).ToHexString();
                    if (validator.Equals(publicKey))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
            }
            //只有共识节点才能开启共识
            if (found)
            {
                Consensus = ActorSystem.ActorOf(ConsensusService.Props(LocalNode, TaskManager, wallet));
                Consensus.Tell(new ConsensusService.Start());
            }
        }
Exemple #4
0
        public void CanReachConsensus()
        {
            var sut = new ConsensusService(3);

            Assert.IsFalse(sut.SignalAccept(1));
            Assert.IsFalse(sut.SignalAccept(2));
            Assert.IsTrue(sut.SignalAccept(3));
        }
Exemple #5
0
 private void _StartConsensus(Wallet wallet)
 {
     if (Consensus == null)
     {
         Consensus = Context.ActorOf(ConsensusService.Props(LocalNode, TaskManager, wallet, ChainHash), $"ConsensusService");
         Consensus.Tell(new ConsensusService.Start());
     }
 }
Exemple #6
0
        private bool OnStartConsensusCommand(string[] args)
        {
            if (consensus != null)
            {
                return(true);
            }
            if (Program.Wallet == null)
            {
                Console.WriteLine("You have to open the wallet first.");
                return(true);
            }
            string log_dictionary = Path.Combine(AppContext.BaseDirectory, "Logs");

            consensus  = new ConsensusService(LocalNode, Program.Wallet, log_dictionary);
            ShowPrompt = false;
            consensus.Start();
            return(true);
        }
Exemple #7
0
 public void StartConsensus(Wallet wallet)
 {
     Consensus = ActorSystem.ActorOf(ConsensusService.Props(this, wallet));
     Consensus.Tell(new ConsensusService.Start());
 }
Exemple #8
0
 public void StartConsensus()
 {
     Consensus = ActorSystem.ActorOf(ConsensusService.Props(this.LocalNode));
     //Consensus.Tell(new ConsensusService.Start { IgnoreRecoveryLogs = ignoreRecoveryLogs }, Blockchain);
 }
Exemple #9
0
        public void CantSignalAcceptOutOfBounds()
        {
            var sut = new ConsensusService(3);

            Assert.IsFalse(sut.SignalAccept(4));
        }
Exemple #10
0
 public void StartConsensus(Wallet wallet)
 {
     Consensus = ActorSystem.ActorOf(ConsensusService.Props(this.LocalNode, this.TaskManager, wallet));
     Consensus.Tell(new ConsensusService.Start());
 }
Exemple #11
0
 public void StartConsensus(UInt160 chainHash, Wallet wallet)
 {
     Consensus = ActorSystem.ActorOf(ConsensusService.Props(this, wallet, chainHash));
     Consensus.Tell(new ConsensusService.Start());
 }
 public void StartConsensus()
 {
     Consensus = ActorSystem.ActorOf(ConsensusService.Props(this, this._hostEnv, this._hub, this.LocalNode, TheBlockchain));
     Consensus.Tell(new ConsensusService.Startup {
     }, TheBlockchain);
 }