Ejemplo n.º 1
0
 /// <summary>
 /// Currently the <paramref name="url"/> is required as it needs to be configurable for testing.
 /// <para>
 /// In a production/live scenario the sidechain and mainnet federation nodes should run on the same machine.
 /// </para>
 /// </summary>
 public FederationGatewayClient(
     ILoggerFactory loggerFactory,
     ICounterChainSettings counterChainSettings,
     IHttpClientFactory httpClientFactory)
     : base(loggerFactory, httpClientFactory, counterChainSettings.CounterChainApiPort, "FederationGateway", $"http://{counterChainSettings.CounterChainApiHost}")
 {
 }
 public CollateralFederationManager(NodeSettings nodeSettings, Network network, ILoggerFactory loggerFactory, IKeyValueRepository keyValueRepo, ISignals signals,
                                    ICounterChainSettings counterChainSettings, IFullNode fullNode, IHttpClientFactory httpClientFactory)
     : base(nodeSettings, network, loggerFactory, keyValueRepo, signals)
 {
     this.counterChainSettings = counterChainSettings;
     this.loggerFactory        = loggerFactory;
     this.fullNode             = fullNode;
     this.httpClientFactory    = httpClientFactory;
 }
 public JoinFederationRequestService(ICounterChainSettings counterChainSettings, IFullNode fullNode, IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, Network network, NodeSettings nodeSettings, VotingManager votingManager)
 {
     this.counterChainSettings = counterChainSettings;
     this.fullNode             = fullNode;
     this.httpClientFactory    = httpClientFactory;
     this.loggerFactory        = loggerFactory;
     this.network       = network as PoANetwork;
     this.nodeSettings  = nodeSettings;
     this.votingManager = votingManager;
 }
        public async Task TestRetriesCountAsync()
        {
            ICounterChainSettings federationSettings = Substitute.For <ICounterChainSettings>();

            var testClient = new TestRestApiClient(this.loggerFactory, federationSettings, this.httpClientFactory);

            HttpResponseMessage result = await testClient.CallThatWillAlwaysFail().ConfigureAwait(false);

            Assert.Equal(RestApiClientBase.RetryCount, testClient.RetriesCount);
            Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
        }
        public CollateralChecker(IHttpClientFactory httpClientFactory, ICounterChainSettings settings, IFederationManager federationManager,
                                 ISignals signals, Network network, IAsyncProvider asyncProvider, INodeLifetime nodeLifetime)
        {
            this.federationManager = federationManager;
            this.signals           = signals;
            this.asyncProvider     = asyncProvider;

            this.maxReorgLength        = AddressIndexer.GetMaxReorgOrFallbackMaxReorg(network);
            this.cancellationSource    = CancellationTokenSource.CreateLinkedTokenSource(nodeLifetime.ApplicationStopping);
            this.locker                = new object();
            this.balancesDataByAddress = new Dictionary <string, AddressIndexerData>();
            this.logger                = LogManager.GetCurrentClassLogger();
            this.blockStoreClient      = new BlockStoreClient(httpClientFactory, $"http://{settings.CounterChainApiHost}", settings.CounterChainApiPort);
        }
        public FederationManager(
            IFullNode fullNode,
            Network network,
            NodeSettings nodeSettings,
            ISignals signals,
            ICounterChainSettings counterChainSettings = null)
        {
            this.counterChainSettings = counterChainSettings;
            this.fullNode             = fullNode;
            this.network      = Guard.NotNull(network as PoANetwork, nameof(network));
            this.nodeSettings = Guard.NotNull(nodeSettings, nameof(nodeSettings));
            this.signals      = Guard.NotNull(signals, nameof(signals));

            this.logger = LogManager.GetCurrentClassLogger();
            this.locker = new object();
        }
        public CollateralChecker(ILoggerFactory loggerFactory,
                                 IHttpClientFactory httpClientFactory,
                                 ICounterChainSettings settings,
                                 IFederationManager federationManager,
                                 ISignals signals)
        {
            this.federationManager = federationManager;
            this.signals           = signals;

            this.cancellationSource = new CancellationTokenSource();
            this.locker             = new object();
            this.depositsByAddress  = new Dictionary <string, Money>();
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.blockStoreClient   = new BlockStoreClient(loggerFactory, httpClientFactory, $"http://{settings.CounterChainApiHost}", settings.CounterChainApiPort);
            this.isInitialized      = false;
        }
Ejemplo n.º 8
0
        public FederationManager(
            ICounterChainSettings counterChainSettings,
            IFullNode fullNode,
            Network network,
            NodeSettings nodeSettings,
            ILoggerFactory loggerFactory,
            ISignals signals)
        {
            this.counterChainSettings = counterChainSettings;
            this.fullNode             = fullNode;
            this.network      = Guard.NotNull(network as PoANetwork, nameof(network));
            this.nodeSettings = Guard.NotNull(nodeSettings, nameof(nodeSettings));
            this.signals      = Guard.NotNull(signals, nameof(signals));

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
            this.locker = new object();
        }
Ejemplo n.º 9
0
 public CollateralPoAMiner(IConsensusManager consensusManager, IDateTimeProvider dateTimeProvider, Network network, INodeLifetime nodeLifetime, ILoggerFactory loggerFactory,
                           IInitialBlockDownloadState ibdState, BlockDefinition blockDefinition, ISlotsManager slotsManager, IConnectionManager connectionManager, JoinFederationRequestMonitor joinFederationRequestMonitor,
                           PoABlockHeaderValidator poaHeaderValidator, IFederationManager federationManager, IIntegrityValidator integrityValidator, IWalletManager walletManager, ChainIndexer chainIndexer,
                           INodeStats nodeStats, VotingManager votingManager, PoAMinerSettings poAMinerSettings, ICollateralChecker collateralChecker, IAsyncProvider asyncProvider, ICounterChainSettings counterChainSettings, IIdleFederationMembersKicker idleFederationMembersKicker)
     : base(consensusManager, dateTimeProvider, network, nodeLifetime, loggerFactory, ibdState, blockDefinition, slotsManager, connectionManager,
            poaHeaderValidator, federationManager, integrityValidator, walletManager, nodeStats, votingManager, poAMinerSettings, asyncProvider, idleFederationMembersKicker)
 {
     this.counterChainNetwork          = counterChainSettings.CounterChainNetwork;
     this.collateralChecker            = collateralChecker;
     this.encoder                      = new CollateralHeightCommitmentEncoder(this.logger);
     this.chainIndexer                 = chainIndexer;
     this.joinFederationRequestMonitor = joinFederationRequestMonitor;
 }
 public TestRestApiClient(ILoggerFactory loggerFactory, ICounterChainSettings settings, IHttpClientFactory httpClientFactory)
     : base(loggerFactory, httpClientFactory, settings.CounterChainApiPort, "FederationGateway", "http://localhost")
 {
     this.RetriesCount = 0;
 }
        public CollateralChecker(ILoggerFactory loggerFactory, IHttpClientFactory httpClientFactory, ICounterChainSettings settings,
                                 IFederationManager federationManager, ISignals signals, Network network, IAsyncProvider asyncProvider)
        {
            this.federationManager = federationManager;
            this.signals           = signals;
            this.asyncProvider     = asyncProvider;

            this.maxReorgLength        = AddressIndexer.GetMaxReorgOrFallbackMaxReorg(network);
            this.cancellationSource    = new CancellationTokenSource();
            this.locker                = new object();
            this.balancesDataByAddress = new Dictionary <string, AddressIndexerData>();
            this.logger                = loggerFactory.CreateLogger(this.GetType().FullName);
            this.blockStoreClient      = new BlockStoreClient(loggerFactory, httpClientFactory, $"http://{settings.CounterChainApiHost}", settings.CounterChainApiPort);
        }
 /// <summary>
 /// The class constructor.
 /// </summary>
 /// <param name="counterChainSettings">The <see cref="ICounterChainSettings"/>.</param>
 /// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
 public ExternalApiClient(ICounterChainSettings counterChainSettings, IHttpClientFactory httpClientFactory)
     : base(httpClientFactory, counterChainSettings.CounterChainApiPort, "ExternalApi", $"http://{counterChainSettings.CounterChainApiHost}")
 {
 }