예제 #1
0
        private async void RealizedPrescriptionBlockChainInit()
        {
            blockChainClient_realized = new BlockChainClient(NetworkUtils.GetLocalIPAddress().ToString(), "6067");

            realizedPrescriptions = new BlockChain(blockChainClient_realized, "realizedPrescriptionsBlockChain");

            blockChainServer_realized = new BlockChainServer(realizedPrescriptions, NetworkUtils.GetLocalIPAddress().ToString(), "6067");
            blockChainServer_realized.Start();

            foreach (string ipAddress in availableIpAddresses)
            {
                if (!ipAddress.Equals(NetworkUtils.GetLocalIPAddress().ToString()))
                {
                    blockChainClient_realized.Connect(ipAddress, "6067");
                }
            }

            if (realizedPrescriptions.blockChainClient.GetNumberOfConnectedPeers() >= 2)
            {
                realizedPrescriptions.UpdateBlockChain();
            }
            else
            {
                TraceingManager.Message(LogMessages.LessThen2pearsMessage);
            }
            TraceingManager.Message(LogMessages.RealizedPrescryptionsBlockChainInitializedMessage);
        }
예제 #2
0
        public BlockChain(BlockChainClient blockChainClient, string blockChainName)
        {
            this.blockChainClient = blockChainClient;
            this.blockChainName   = blockChainName;
            this.updateThread     = new Thread(new ThreadStart(InternalUpdateBlockChain));
            this.addThread        = new Thread(new ThreadStart(InternalAdd));

            blocks = BlockChainSerializer.deserialize(blockChainName);

            //Creating Genesis Block
            if (blocks == null)
            {
                blocks = new List <Block>();
                blocks.Add(new Block(null, null));
            }


            validator = new BlockChainValidator(blockChainName);
        }