Ejemplo n.º 1
0
        public LocalClient(LocalClientType type, BlockchainDaemon blockchainDaemon, IBoundedStorage<NetworkAddressKey, NetworkAddressWithTime> knownAddressStorage)
        {
            this._type = type;

            this.blockchainDaemon = blockchainDaemon;
            this.shutdownToken = new CancellationTokenSource();

            this.knownAddressCache = new BoundedCache<NetworkAddressKey, NetworkAddressWithTime>
            (
                "KnownAddressCache",
                dataStorage: knownAddressStorage,
                maxFlushMemorySize: 5.THOUSAND(),
                maxCacheMemorySize: 500.THOUSAND(),
                sizeEstimator: knownAddress => 40
            );

            this.connectWorker = new Worker("LocalClient.ConnectWorker", ConnectWorker, true, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
            this.requestBlocksWorker = new Worker("LocalClient.RequestBlocksWorker", RequestBlocksWorker, true, TimeSpan.FromMilliseconds(200), TimeSpan.FromMilliseconds(5000));
            this.requestHeadersWorker = new Worker("LocalClient.RequestHeadersWorker", RequestHeadersWorker, true, TimeSpan.FromMilliseconds(200), TimeSpan.FromMilliseconds(5000));
            this.statsWorker = new Worker("LocalClient.StatsWorker", StatsWorker, true, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));

            this.blockchainDaemon.OnWinningBlockChanged += OnWinningBlockChanged;

            switch (this.Type)
            {
                case LocalClientType.MainNet:
                    Messaging.Port = 8333;
                    Messaging.Magic = Messaging.MAGIC_MAIN;
                    break;

                case LocalClientType.TestNet3:
                    Messaging.Port = 18333;
                    Messaging.Magic = Messaging.MAGIC_TESTNET3;
                    break;

                case LocalClientType.ComparisonToolTestNet:
                    Messaging.Port = 18444;
                    Messaging.Magic = Messaging.MAGIC_COMPARISON_TOOL;
                    break;
            }
        }
Ejemplo n.º 2
0
        public LocalClient(LocalClientType type, BlockchainDaemon blockchainDaemon, IBoundedStorage <NetworkAddressKey, NetworkAddressWithTime> knownAddressStorage)
        {
            this._type = type;

            this.blockchainDaemon = blockchainDaemon;
            this.shutdownToken    = new CancellationTokenSource();

            this.knownAddressCache = new BoundedCache <NetworkAddressKey, NetworkAddressWithTime>
                                     (
                "KnownAddressCache",
                dataStorage: knownAddressStorage,
                maxFlushMemorySize: 5.THOUSAND(),
                maxCacheMemorySize: 500.THOUSAND(),
                sizeEstimator: knownAddress => 40
                                     );

            this.connectWorker        = new Worker("LocalClient.ConnectWorker", ConnectWorker, true, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
            this.requestBlocksWorker  = new Worker("LocalClient.RequestBlocksWorker", RequestBlocksWorker, true, TimeSpan.FromMilliseconds(200), TimeSpan.FromMilliseconds(5000));
            this.requestHeadersWorker = new Worker("LocalClient.RequestHeadersWorker", RequestHeadersWorker, true, TimeSpan.FromMilliseconds(200), TimeSpan.FromMilliseconds(5000));
            this.statsWorker          = new Worker("LocalClient.StatsWorker", StatsWorker, true, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));

            this.blockchainDaemon.OnWinningBlockChanged += OnWinningBlockChanged;

            switch (this.Type)
            {
            case LocalClientType.MainNet:
                Messaging.Port  = 8333;
                Messaging.Magic = Messaging.MAGIC_MAIN;
                break;

            case LocalClientType.TestNet3:
                Messaging.Port  = 18333;
                Messaging.Magic = Messaging.MAGIC_TESTNET3;
                break;

            case LocalClientType.ComparisonToolTestNet:
                Messaging.Port  = 18444;
                Messaging.Magic = Messaging.MAGIC_COMPARISON_TOOL;
                break;
            }
        }
 /// <summary>
 /// Constructs the default token replay cache with the specified
 /// capacity and purge interval.
 /// </summary>
 /// <param name="capacity">The capacity of the token cache</param>
 /// <param name="purgeInterval">The time interval after which the cache must be purged</param>
 public DefaultTokenReplayCache(int capacity, TimeSpan purgeInterval)
     : base()
 {
     _internalCache = new BoundedCache <SecurityToken>(capacity, purgeInterval, StringComparer.Ordinal);
 }
 /// <summary>
 /// Constructs the default token replay cache with the specified 
 /// capacity and purge interval.
 /// </summary>
 /// <param name="capacity">The capacity of the token cache</param>
 /// <param name="purgeInterval">The time interval after which the cache must be purged</param>
 public DefaultTokenReplayCache(int capacity, TimeSpan purgeInterval)
     : base()
 {
     _internalCache = new BoundedCache<SecurityToken>(capacity, purgeInterval, StringComparer.Ordinal);
 }