Ignore:
Timestamp:
Jun 17, 2010, 5:11:02 PM (11 years ago)
Author:
Paul Lelgemann
Message:

+ CrypP2P: Return types of synchronous methods Store/Retrieve/Remove changed
o Work on the distributed KeySearcher

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher/P2P/Nodes/P2PHelper.cs

    r1651 r1665  
    22using System.IO;
    33using Cryptool.P2P;
     4using Cryptool.P2P.Internal;
    45
    56namespace KeySearcher.P2P.Nodes
     
    78    class P2PHelper
    89    {
    9         private KeySearcher _keySearcher;
     10        private readonly KeySearcher _keySearcher;
    1011
    1112        public P2PHelper(KeySearcher keySearcher)
     
    1415        }
    1516
    16         internal static bool UpdateInDht(NodeBase nodeToUpdate)
     17        internal static RequestResult UpdateInDht(NodeBase nodeToUpdate)
    1718        {
    1819            var memoryStream = new MemoryStream();
     
    5253        }
    5354
    54         internal void UpdateFromDht(NodeBase nodeToUpdate)
     55        internal RequestResult UpdateFromDht(NodeBase nodeToUpdate, bool forceUpdate = false)
    5556        {
    56             if (nodeToUpdate.LastUpdate > DateTime.Now.Subtract(new TimeSpan(0, 0, 5)))
     57            //var cacheActive = nodeToUpdate.LastUpdateResult != RequestResultType.KeyNotFound;
     58
     59            if (!forceUpdate && nodeToUpdate.LastUpdate > DateTime.Now.Subtract(new TimeSpan(0, 0, 5)))
    5760            {
    58                 return;
     61                return new RequestResult { Status = RequestResultType.Success };
    5962            }
    6063
    6164            nodeToUpdate.LastUpdate = DateTime.Now;
    6265
    63             var nodeBytes = P2PManager.Retrieve(KeyInDht(nodeToUpdate));
     66            var requestResult = P2PManager.Retrieve(KeyInDht(nodeToUpdate));
     67            var nodeBytes = requestResult.Data;
     68            nodeToUpdate.LastUpdateResult = requestResult.Status;
    6469
    6570            if (nodeBytes == null)
    6671            {
    67                 return;
     72                return requestResult;
    6873            }
    6974
     
    95100                _keySearcher.IntegrateNewResults(nodeToUpdate.Result);
    96101            }
     102
     103            return requestResult;
    97104        }
    98105
Note: See TracChangeset for help on using the changeset viewer.