public void AddGenesisBlock(string type)
        {
            switch (type)
            {
            case "credentrails":
                BlockchainCredentials bcCredentials = new BlockchainCredentials();
                Chain.Add(new Block(DateTime.Now, null, bcCredentials));
                break;

            case "data":
                BlockchainData bcData = new BlockchainData();
                Chain.Add(new Block(DateTime.Now, null, bcData));
                break;

            case "reports":
                BlockchainReports bcReports = new BlockchainReports();
                Chain.Add(new Block(DateTime.Now, null, bcReports));
                break;

            case "ratings":
                BlockchainRatings bcRatings = new BlockchainRatings();
                Chain.Add(new Block(DateTime.Now, null, bcRatings));
                break;
            }
        }
 public Block(DateTime timeStamp, string previousHash, BlockchainRatings data)
 {
     Index        = 0;
     TimeStamp    = timeStamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff");
     PreviousHash = previousHash;
     DataRatings  = data;
     Hash         = CalculateHash();
 }
Exemplo n.º 3
0
        private void BtnDisapprove_Click(object sender, RoutedEventArgs e)
        {
            MessagePack       mp     = new MessagePack();
            var               tmp    = lstReports.SelectedItem as ArticleReports;
            BlockchainRatings rating = new BlockchainRatings(UserID, -1, tmp.ReportID, false);

            mp.SmObj = new Block(System.DateTime.Now, null, rating);
            mp.Text  = "newBlockRatings";
            byte[] data = Blockchain.ObjectToByteArray(mp);
            sendingClient.Send(data, data.Length);
            MessageBox.Show("Operacja zakończona powodzeniem.");
            btnApprove.IsEnabled    = false;
            btnDisapprove.IsEnabled = false;
            AR[lstReports.SelectedIndex].DownVotes++;
            CollectionViewSource.GetDefaultView(lstReports.ItemsSource).Refresh();
        }
Exemplo n.º 4
0
        private void BtnTrusted_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult boxResult = MessageBox.Show("Operacji nie można cofnąć. Czy jesteś pewny/a?", "UWAGA", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (boxResult == MessageBoxResult.Yes)
            {
                MessagePack       mp     = new MessagePack();
                var               tmp    = lstUsers.SelectedItem as UserRankBinding;
                BlockchainRatings rating = new BlockchainRatings(UserID, tmp.UserID, -1, true);

                mp.SmObj = new Block(System.DateTime.Now, null, rating);
                mp.Text  = "newBlockRatings";
                byte[] data = Blockchain.ObjectToByteArray(mp);
                sendingClient.Send(data, data.Length);
                //MessageBox.Show("Operacja zakończona powodzeniem.");
                btnTrusted.IsEnabled = false;
                btnFake.IsEnabled    = false;
                ratedUsers.Add(tmp.UserID);
                userBinding[lstUsers.SelectedIndex].Trusted++;
                CollectionViewSource.GetDefaultView(lstUsers.ItemsSource).Refresh();
            }
        }