Changeset 1561


Ignore:
Timestamp:
Jun 1, 2010, 10:08:43 PM (12 years ago)
Author:
Sven Rech
Message:

quadratic sieve

Location:
trunk/CrypPlugins/QuadraticSieve
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/QuadraticSieve/PeerToPeer.cs

    r1558 r1561  
    8181            int loadEnd = head; //we know, that the DHT entries from 1 to "loadEnd" are unknown to us, so we will load these when we have no other things to do
    8282            int loadIndex = 0;
     83            uint downloaded = 0;
     84            uint uploaded = 0;
    8385
    8486            try
     
    9597                        P2PManager.Store(HeadIdentifier(), System.Text.ASCIIEncoding.ASCII.GetBytes(head.ToString()));
    9698                        //TODO: If versioning system tells us, that there is already a newer head entry, we ignore this and don't store ours
     99                        uploaded += (uint)yield.Length;
     100                        ShowTransfered(downloaded, uploaded);
    97101                    }
    98102                    else                      //if there is nothing to store, we can load the yields up to "loadEnd".
     
    101105                        {
    102106                            byte[] yield = ReadYield(loadIndex);
     107                            downloaded += (uint)yield.Length;
     108                            ShowTransfered(downloaded, uploaded);
    103109                            loadqueue.Enqueue(yield);
    104110                            SetProgressYield(loadIndex, YieldStatus.OthersLoaded);
     
    119125        }
    120126
     127        private void ShowTransfered(uint downloaded, uint uploaded)
     128        {
     129            string s1 = ((downloaded / 1024.0) / 1024).ToString();
     130            string size1 = s1.Substring(0, (s1.Length < 3) ? s1.Length : 3);
     131            string s2 = ((uploaded / 1024.0) / 1024).ToString();
     132            string size2 = s1.Substring(0, (s2.Length < 3) ? s2.Length : 3);
     133            quadraticSieveQuickWatchPresentation.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     134            {               
     135                quadraticSieveQuickWatchPresentation.relationsInfo.Content = "Downloaded " + s1 + " MB! Uploaded " + s2 + " MB!";
     136            }, null);
     137        }
     138
    121139        private void SetProgressYield(int index, YieldStatus status)
    122140        {
     
    175193        /// <summary>
    176194        /// Compresses the yield and puts it in the DHT.
    177         /// Returns the compressed size
    178         /// </summary>
    179         public int Put(byte[] serializedYield)
     195        /// </summary>
     196        public void Put(byte[] serializedYield)
    180197        {
    181198            //Compress:
     
    191208
    192209            //store in queue, so the LoadStoreThread can store it in the DHT later:
    193             storequeue.Enqueue(compressedYield);
    194             return compressedYield.Length;
     210            storequeue.Enqueue(compressedYield);           
    195211        }
    196212
     
    247263                MemoryStream memstream = new MemoryStream();
    248264                memstream.Write(dhtFactorManagerBytes, 0, dhtFactorManagerBytes.Length);
     265                memstream.Position = 0;
    249266                BinaryFormatter bformatter = new BinaryFormatter();
    250267                try
  • trunk/CrypPlugins/QuadraticSieve/QuadraticSieve.cs

    r1558 r1561  
    6262        private FactorManager factorManager;
    6363        private PeerToPeer peerToPeer;
    64         private uint sumSize = 0;
    6564        private bool usePeer2Peer;
    6665
     
    169168                peerToPeer.SetNumber(InputNumber);
    170169            }
    171 
    172             sumSize = 0;
     170                       
    173171            userStopped = false;
    174172
     
    427425        private void prepareSieving(IntPtr conf, int update, IntPtr core_sieve_fcn, int max_relations)
    428426        {
    429             sumSize = 0;
    430427            int threads = Math.Min(settings.CoresUsed, Environment.ProcessorCount-1);
    431428            MethodInfo getObjFromConf = msieve.GetMethod("getObjFromConf");
     
    504501                    {
    505502                        byte[] serializedYield = (byte[])serializeYield.Invoke(null, new object[] { yield });
    506                         int compressedSize = peerToPeer.Put(serializedYield);
    507                         sumSize += (uint)compressedSize;
    508503                    }
    509504
     
    551546                }
    552547                , null);
    553             }
    554 
    555             if (usePeer2Peer)
    556             {
    557                 quadraticSieveQuickWatchPresentation.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
    558                 {
    559                     string s = ((sumSize / 1024.0) / 1024).ToString();
    560                     string size = s.Substring(0, (s.Length < 3) ? s.Length : 3);
    561                     quadraticSieveQuickWatchPresentation.relationsInfo.Content = size + " MB compressed relation data available!";
    562                 }, null);
    563548            }
    564549        }
  • trunk/CrypPlugins/QuadraticSieve/QuadraticSievePresentation.xaml.cs

    r1522 r1561  
    3434            Grid.SetRow(progressYields, 0);
    3535            grid.Children.Add(progressYields);
     36            progressYields.MaxWidth = 200;
    3637        }
    3738
Note: See TracChangeset for help on using the changeset viewer.