Exemplo n.º 1
0
 /// <summary>
 /// Constructor that initializes the maps as null references. To use this class init must be
 /// called that creates a new class with the private constructor.
 /// </summary>
 /// <param name="peerUrgency"></param>
 /// <param name="intervalSeconds"></param>
 public DefaultMaintenance(int peerUrgency, int[] intervalSeconds)
 {
     _peerMapVerified = null;
     _peerMapNonVerified = null;
     _offlineMap = null;
     _shutdownMap = null;
     _exceptionMap = null;
     _peerUrgency = peerUrgency;
     _intervalSeconds = intervalSeconds;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor that initializes the maps as null references. To use this class init must be
 /// called that creates a new class with the private constructor.
 /// </summary>
 /// <param name="peerUrgency"></param>
 /// <param name="intervalSeconds"></param>
 public DefaultMaintenance(int peerUrgency, int[] intervalSeconds)
 {
     _peerMapVerified    = null;
     _peerMapNonVerified = null;
     _offlineMap         = null;
     _shutdownMap        = null;
     _exceptionMap       = null;
     _peerUrgency        = peerUrgency;
     _intervalSeconds    = intervalSeconds;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a new maintenance class with the verified and non-verified map.
 /// </summary>
 /// <param name="peerMapVerified">The verified map.</param>
 /// <param name="peerMapNonVerified">The non-verified map.</param>
 /// <param name="offlineMap">The offline map.</param>
 /// <param name="shutdownMap">The shutdown map.</param>
 /// <param name="exceptionMap">The exception map.</param>
 /// <param name="peerUrgency">The number of peers that should be in the verified map. If the
 /// number is lower, urgency is set to yes and we are looking for peers in the non-verified map.</param>
 /// <param name="intervalSeconds"></param>
 private DefaultMaintenance(IList<IDictionary<Number160, PeerStatistic>> peerMapVerified,
     IList<IDictionary<Number160, PeerStatistic>> peerMapNonVerified,
     ConcurrentCacheMap<Number160, PeerAddress> offlineMap,
     ConcurrentCacheMap<Number160, PeerAddress> shutdownMap,
     ConcurrentCacheMap<Number160, PeerAddress> exceptionMap, int peerUrgency, int[] intervalSeconds)
 {
     _peerMapVerified = peerMapVerified;
     _peerMapNonVerified = peerMapNonVerified;
     _offlineMap = offlineMap;
     _shutdownMap = shutdownMap;
     _exceptionMap = exceptionMap;
     _peerUrgency = peerUrgency;
     _intervalSeconds = intervalSeconds;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new maintenance class with the verified and non-verified map.
 /// </summary>
 /// <param name="peerMapVerified">The verified map.</param>
 /// <param name="peerMapNonVerified">The non-verified map.</param>
 /// <param name="offlineMap">The offline map.</param>
 /// <param name="shutdownMap">The shutdown map.</param>
 /// <param name="exceptionMap">The exception map.</param>
 /// <param name="peerUrgency">The number of peers that should be in the verified map. If the
 /// number is lower, urgency is set to yes and we are looking for peers in the non-verified map.</param>
 /// <param name="intervalSeconds"></param>
 private DefaultMaintenance(IList <IDictionary <Number160, PeerStatistic> > peerMapVerified,
                            IList <IDictionary <Number160, PeerStatistic> > peerMapNonVerified,
                            ConcurrentCacheMap <Number160, PeerAddress> offlineMap,
                            ConcurrentCacheMap <Number160, PeerAddress> shutdownMap,
                            ConcurrentCacheMap <Number160, PeerAddress> exceptionMap, int peerUrgency, int[] intervalSeconds)
 {
     _peerMapVerified    = peerMapVerified;
     _peerMapNonVerified = peerMapNonVerified;
     _offlineMap         = offlineMap;
     _shutdownMap        = shutdownMap;
     _exceptionMap       = exceptionMap;
     _peerUrgency        = peerUrgency;
     _intervalSeconds    = intervalSeconds;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a bag for the peers. This peer knows a lot about close peers. The further away the peers are,
 /// the less known they are. Distance is measured with XOR of the peer ID.
 /// E.g., the distance of peer with ID 0x12 and peer with ID 0x28 is 0x3a.
 /// </summary>
 /// <param name="peerMapConfiguration">The configuration values for this map.</param>
 public PeerMap(PeerMapConfiguration peerMapConfiguration)
 {
     Self = peerMapConfiguration.Self;
     if (Self == null || Self.IsZero)
     {
         throw new ArgumentException("Zero or null are not valid peer IDs.");
     }
     BagSizeVerified = peerMapConfiguration.BagSizeVerified;
     BagSizeOverflow = peerMapConfiguration.BagSizeOverflow;
     _offlineCount   = peerMapConfiguration.OfflineCount;
     _peerFilters    = peerMapConfiguration.PeerFilters;
     PeerMapVerified = InitFixedMap(BagSizeVerified, false);
     PeerMapOverflow = InitFixedMap(BagSizeOverflow, true);
     // _bagSizeVerified * Number160.Bits should be enough
     _offlineMap   = new ConcurrentCacheMap <Number160, PeerAddress>(peerMapConfiguration.OfflineTimeout, BagSizeVerified * Number160.Bits);
     _shutdownMap  = new ConcurrentCacheMap <Number160, PeerAddress>(peerMapConfiguration.ShutdownTimeout, BagSizeVerified * Number160.Bits);
     _exceptionMap = new ConcurrentCacheMap <Number160, PeerAddress>(peerMapConfiguration.ExceptionTimeout, BagSizeVerified * Number160.Bits);
     _maintenance  = peerMapConfiguration.Maintenance.Init(PeerMapVerified, PeerMapOverflow, _offlineMap,
                                                           _shutdownMap, _exceptionMap);
     _peerVerification = peerMapConfiguration.IsPeerVerification;
 }
Exemplo n.º 6
0
 public IMaintenance Init(IList<IDictionary<Number160, PeerStatistic>> peerMapVerified, IList<IDictionary<Number160, PeerStatistic>> peerMapNonVerified, ConcurrentCacheMap<Number160, PeerAddress> offlineMap,
     ConcurrentCacheMap<Number160, PeerAddress> shutdownMap, ConcurrentCacheMap<Number160, PeerAddress> exceptionMap)
 {
     return new DefaultMaintenance(peerMapVerified, peerMapNonVerified, offlineMap, shutdownMap, exceptionMap, _peerUrgency, _intervalSeconds);
 }
Exemplo n.º 7
0
 public IMaintenance Init(IList <IDictionary <Number160, PeerStatistic> > peerMapVerified, IList <IDictionary <Number160, PeerStatistic> > peerMapNonVerified, ConcurrentCacheMap <Number160, PeerAddress> offlineMap,
                          ConcurrentCacheMap <Number160, PeerAddress> shutdownMap, ConcurrentCacheMap <Number160, PeerAddress> exceptionMap)
 {
     return(new DefaultMaintenance(peerMapVerified, peerMapNonVerified, offlineMap, shutdownMap, exceptionMap, _peerUrgency, _intervalSeconds));
 }