コード例 #1
0
        public virtual Task OnNextAsync(SourceSignedMessage msg)
        {
            var item = msg as ChatMsg;

            if (item != null)
            {
                var info = $"=={item.Created}==         {item.From} said: {item.Text}";
                Console.WriteLine(info);

                OnNodeChat?.Invoke(item);
            }
            return(Task.CompletedTask);
        }
コード例 #2
0
        public virtual void Send2P2pNetwork(SourceSignedMessage msg)
        {
            _log.LogInformation($"Consensus: SendMessage Called: msg From: {msg.From}");

            var sign = msg.Sign(NodeService.Instance.PosWallet.PrivateKey, msg.From);
            //_log.LogInformation($"Consensus: Sign {msg.Hash} got: {sign} by prvKey: {NodeService.Instance.PosWallet.PrivateKey} pubKey: {msg.From}");

            int waitCount = 5;

            while (LocalNode.Singleton.RemoteNodes.Count < 1 && waitCount > 0)
            {
                _log.LogWarning("Not connected to Lyra Network. Delay sending... ");
                Task.Delay(1000).Wait();
                waitCount--;
            }

            _localNode.Tell(msg);
        }
コード例 #3
0
        void OnNextConsensusMessage(SourceSignedMessage item)
        {
            _log.LogInformation($"Consensus: OnNextAsyncImpl Called: msg From: {item.From}");

            // verify the signatures of msg. make sure it is from the right node.
            //var nodeConfig = null;
            if (!item.VerifySignature(item.From))
            {
                _log.LogInformation($"Consensus: bad signature: {item.Hash} sign: {item.Signature} by pubKey: {item.From}");
                _log.LogInformation($"Consensus: hash: {item.Hash} rehash: {item.CalculateHash()}");
                return;
            }

            switch (item)
            {
            case AuthorizingMsg msg:
                OnPrePrepare(msg);
                break;

            case AuthorizedMsg authed:
                OnPrepare(authed);
                break;

            case AuthorizerCommitMsg commited:
                OnCommit(commited);
                break;

            case ChatMsg chat when chat.MsgType == ChatMessageType.NodeUp:
                OnNodeUp(chat);
                break;

            case ChatMsg bbb when bbb.MsgType == ChatMessageType.StakingChanges:
                OnBillBoardBroadcast(bbb);
                break;

            case ChatMsg bcc when bcc.MsgType == ChatMessageType.BlockConsolidation:
                OnBlockConsolication(bcc);
                break;

            default:
                // log msg unknown
                break;
            }
        }
コード例 #4
0
 public bool IsMessageFromSeed0(SourceSignedMessage msg)
 {
     return(msg.From == ProtocolSettings.Default.StandbyValidators[0]);
 }