source: trunk/CrypPlugins/KeySearcher/P2P/Nodes/Leaf.cs @ 1647

Last change on this file since 1647 was 1647, checked in by Paul Lelgemann, 12 years ago

o Work on the distributed KeySearcher

File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Numerics;
4using KeySearcher.Helper;
5
6namespace KeySearcher.P2P.Nodes
7{
8    class Leaf : NodeBase
9    {
10        internal DateTime LastReservationDate;
11
12        public Leaf(P2PHelper p2PHelper, KeyQualityHelper keyQualityHelper, Node parentNode, BigInteger id, string distributedJobIdentifier)
13            : base(p2PHelper, keyQualityHelper, parentNode, id, id, distributedJobIdentifier)
14        {
15        }
16
17        public void HandleResults(LinkedList<KeySearcher.ValueKey> result)
18        {
19            Result = result;
20            UpdateDht();
21        }
22
23        public BigInteger PatternId()
24        {
25            return From;
26        }
27
28        public override NodeBase CalculatableNode(bool useReservedNodes)
29        {
30            return this;
31        }
32
33        public bool ReserveLeaf()
34        {
35            LastReservationDate = DateTime.UtcNow;
36            return P2PHelper.UpdateInDht(this);
37        }
38
39        public override bool IsReserverd()
40        {
41            var dateFiveMinutesBefore = DateTime.UtcNow.Subtract(new TimeSpan(0, 5, 0));
42            var isReserverd = dateFiveMinutesBefore < LastReservationDate;
43            return isReserverd;
44        }
45    }
46}
Note: See TracBrowser for help on using the repository browser.