Skip to content

Commit

Permalink
fix codestyle violations part 2 (stratisproject#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
noescape00 authored and bokobza committed Dec 13, 2018
1 parent c7c822f commit 1b4aa0c
Show file tree
Hide file tree
Showing 56 changed files with 304 additions and 356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Stratis.FederatedPeg.Features.FederationGateway.Interfaces;
using Stratis.FederatedPeg.Features.FederationGateway.Models;


namespace Stratis.FederatedPeg.Features.FederationGateway.Controllers
{
public static class FederationGatewayRouteEndPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.Logging;
using NBitcoin;
using Stratis.Bitcoin.Connection;
using Stratis.Bitcoin.Features.Wallet;
using Stratis.Bitcoin.Features.Wallet.Models;
using Stratis.Bitcoin.Utilities;
using Stratis.Bitcoin.Utilities.JsonErrors;
using Stratis.Bitcoin.Features.Wallet.Models;
using Stratis.FederatedPeg.Features.FederationGateway.Interfaces;
using Stratis.FederatedPeg.Features.FederationGateway.Models;
using Stratis.FederatedPeg.Features.FederationGateway.Wallet;

namespace Stratis.FederatedPeg.Features.FederationGateway.Controllers
{
using System.Security;

/// <summary>
/// Controller providing operations on a wallet.
/// </summary>
Expand Down Expand Up @@ -100,7 +99,7 @@ public IActionResult GetBalance()
return this.NotFound("No federation wallet found.");
}

var result = wallet.GetSpendableAmount();
(Money ConfirmedAmount, Money UnConfirmedAmount) result = wallet.GetSpendableAmount();

var balance = new AccountBalanceModel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Stratis.SmartContracts.Core;
using Stratis.SmartContracts.Core.State;
using Stratis.SmartContracts.Core.Util;
using Script = NBitcoin.Script;

namespace Stratis.FederatedPeg.Features.FederationGateway
{
Expand Down Expand Up @@ -43,7 +42,7 @@ public FederatedPegBlockDefinition(

public override BlockTemplate Build(ChainedHeader chainTip, Script scriptPubKey)
{
var rewardScript = (chainTip.Height + 1) == this.Network.Consensus.PremineHeight
Script rewardScript = (chainTip.Height + 1) == this.Network.Consensus.PremineHeight
? this.payToMultisigScript
: this.payToMemberScript;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
using Stratis.FederatedPeg.Features.FederationGateway.SourceChain;
using Stratis.FederatedPeg.Features.FederationGateway.TargetChain;
using Stratis.FederatedPeg.Features.FederationGateway.Wallet;
using BlockObserver = Stratis.FederatedPeg.Features.FederationGateway.Notifications.BlockObserver;

[assembly: InternalsVisibleTo("Stratis.FederatedPeg.Features.FederationGateway.Tests")]
[assembly: InternalsVisibleTo("Stratis.FederatedPeg.IntegrationTests")]
Expand All @@ -45,12 +44,8 @@ namespace Stratis.FederatedPeg.Features.FederationGateway
{
internal class FederationGatewayFeature : FullNodeFeature
{
internal const string JsonHttpClientName = "jsonClient";

public const string FederationGatewayFeatureNamespace = "federationgateway";

private readonly IMaturedBlockReceiver maturedBlockReceiver;

private readonly IMaturedBlockSender maturedBlockSender;

private readonly IMaturedBlocksRequester maturedBlockRequester;
Expand All @@ -77,7 +72,7 @@ internal class FederationGatewayFeature : FullNodeFeature

private readonly IFederationGatewaySettings federationGatewaySettings;

private IFullNode fullNode;
private readonly IFullNode fullNode;

private readonly ILoggerFactory loggerFactory;

Expand All @@ -95,7 +90,6 @@ internal class FederationGatewayFeature : FullNodeFeature

public FederationGatewayFeature(
ILoggerFactory loggerFactory,
IMaturedBlockReceiver maturedBlockReceiver,
IMaturedBlockSender maturedBlockSender,
IMaturedBlocksRequester maturedBlocksRequester,
IMaturedBlocksProvider maturedBlocksProvider,
Expand All @@ -117,7 +111,6 @@ public FederationGatewayFeature(
IPartialTransactionRequester partialTransactionRequester)
{
this.loggerFactory = loggerFactory;
this.maturedBlockReceiver = maturedBlockReceiver;
this.maturedBlockSender = maturedBlockSender;
this.maturedBlockRequester = maturedBlocksRequester;
this.maturedBlocksProvider = maturedBlocksProvider;
Expand Down Expand Up @@ -210,7 +203,7 @@ private void AddInlineStats(StringBuilder benchLogs)
"NodeStore.HasSuspended: ".PadRight(LoggingConfiguration.ColumnLength + 1) +
this.crossChainTransferStore.HasSuspended().ToString().PadRight(8)
);
}
}

private void AddComponentStats(StringBuilder benchLog)
{
Expand All @@ -236,81 +229,69 @@ public static IFullNodeBuilder AddFederationGateway(this IFullNodeBuilder fullNo
LoggingConfiguration.RegisterFeatureNamespace<FederationGatewayFeature>(
FederationGatewayFeature.FederationGatewayFeatureNamespace);

fullNodeBuilder.ConfigureFeature(
features =>
fullNodeBuilder.ConfigureFeature(features =>
{
features.AddFeature<FederationGatewayFeature>().DependOn<BlockNotificationFeature>().FeatureServices(
services =>
{
features.AddFeature<FederationGatewayFeature>().DependOn<BlockNotificationFeature>()
.FeatureServices(
services =>
{
services.AddSingleton<IHttpClientFactory, HttpClientFactory>();
services.AddSingleton<IMaturedBlockReceiver, MaturedBlockReceiver>();
services.AddSingleton<IMaturedBlocksRequester, RestMaturedBlockRequester>();
services.AddSingleton<IMaturedBlockSender, RestMaturedBlockSender>();
services.AddSingleton<IMaturedBlocksProvider, MaturedBlocksProvider>();
services.AddSingleton<IBlockTipSender, RestBlockTipSender>();
services.AddSingleton<IFederationGatewaySettings, FederationGatewaySettings>();
services.AddSingleton<IOpReturnDataReader, OpReturnDataReader>();
services.AddSingleton<IDepositExtractor, DepositExtractor>();
services.AddSingleton<IWithdrawalExtractor, WithdrawalExtractor>();
services.AddSingleton<IWithdrawalReceiver, WithdrawalReceiver>();
services.AddSingleton<IEventPersister, EventsPersister>();
services.AddSingleton<FederationGatewayController>();
services
.AddSingleton<IFederationWalletSyncManager, FederationWalletSyncManager>();
services
.AddSingleton<IFederationWalletTransactionHandler,
FederationWalletTransactionHandler>();
services.AddSingleton<IFederationWalletManager, FederationWalletManager>();
services.AddSingleton<ILeaderProvider, LeaderProvider>();
services.AddSingleton<FederationWalletController>();
services.AddSingleton<ICrossChainTransferStore, CrossChainTransferStore>();
services.AddSingleton<ILeaderReceiver, LeaderReceiver>();
services
.AddSingleton<ISignedMultisigTransactionBroadcaster,
SignedMultisigTransactionBroadcaster>();
services
.AddSingleton<IPartialTransactionRequester, PartialTransactionRequester>();
});
services.AddSingleton<IHttpClientFactory, HttpClientFactory>();
services.AddSingleton<IMaturedBlockReceiver, MaturedBlockReceiver>();
services.AddSingleton<IMaturedBlocksRequester, RestMaturedBlockRequester>();
services.AddSingleton<IMaturedBlockSender, RestMaturedBlockSender>();
services.AddSingleton<IMaturedBlocksProvider, MaturedBlocksProvider>();
services.AddSingleton<IBlockTipSender, RestBlockTipSender>();
services.AddSingleton<IFederationGatewaySettings, FederationGatewaySettings>();
services.AddSingleton<IOpReturnDataReader, OpReturnDataReader>();
services.AddSingleton<IDepositExtractor, DepositExtractor>();
services.AddSingleton<IWithdrawalExtractor, WithdrawalExtractor>();
services.AddSingleton<IWithdrawalReceiver, WithdrawalReceiver>();
services.AddSingleton<IEventPersister, EventsPersister>();
services.AddSingleton<FederationGatewayController>();
services.AddSingleton<IFederationWalletSyncManager, FederationWalletSyncManager>();
services.AddSingleton<IFederationWalletTransactionHandler, FederationWalletTransactionHandler>();
services.AddSingleton<IFederationWalletManager, FederationWalletManager>();
services.AddSingleton<ILeaderProvider, LeaderProvider>();
services.AddSingleton<FederationWalletController>();
services.AddSingleton<ICrossChainTransferStore, CrossChainTransferStore>();
services.AddSingleton<ILeaderReceiver, LeaderReceiver>();
services.AddSingleton<ISignedMultisigTransactionBroadcaster, SignedMultisigTransactionBroadcaster>();
services.AddSingleton<IPartialTransactionRequester, PartialTransactionRequester>();
});
});
return fullNodeBuilder;
}

public static IFullNodeBuilder UseFederatedPegPoAMining(this IFullNodeBuilder fullNodeBuilder)
{
fullNodeBuilder.ConfigureFeature(
features =>
fullNodeBuilder.ConfigureFeature(features =>
{
features.AddFeature<PoAFeature>().DependOn<FederationGatewayFeature>().FeatureServices(services =>
{
features.AddFeature<PoAFeature>().DependOn<FederationGatewayFeature>().FeatureServices(
services =>
{
services.AddSingleton<FederationManager>();
services.AddSingleton<PoABlockHeaderValidator>();
services.AddSingleton<IPoAMiner, PoAMiner>();
services.AddSingleton<SlotsManager>();
services.AddSingleton<BlockDefinition, FederatedPegBlockDefinition>();
services.AddSingleton<IBlockBufferGenerator, BlockBufferGenerator>();
});
services.AddSingleton<FederationManager>();
services.AddSingleton<PoABlockHeaderValidator>();
services.AddSingleton<IPoAMiner, PoAMiner>();
services.AddSingleton<SlotsManager>();
services.AddSingleton<BlockDefinition, FederatedPegBlockDefinition>();
services.AddSingleton<IBlockBufferGenerator, BlockBufferGenerator>();
});
});

LoggingConfiguration.RegisterFeatureNamespace<ConsensusFeature>("consensus");
fullNodeBuilder.ConfigureFeature(
features =>
{
features.AddFeature<ConsensusFeature>().FeatureServices(
services =>
{
services.AddSingleton<DBreezeCoinView>();
services.AddSingleton<ICoinView, CachedCoinView>();
services.AddSingleton<ConsensusController>();
services.AddSingleton<IConsensusRuleEngine, SmartContractPoARuleEngine>();
services.AddSingleton<IChainState, ChainState>();
services.AddSingleton<ConsensusQuery>()
.AddSingleton<INetworkDifficulty, ConsensusQuery>(provider => provider.GetService<ConsensusQuery>())
.AddSingleton<IGetUnspentTransaction, ConsensusQuery>(provider => provider.GetService<ConsensusQuery>());
new SmartContractPoARuleRegistration(fullNodeBuilder.Network).RegisterRules(fullNodeBuilder.Network.Consensus);
});
});
fullNodeBuilder.ConfigureFeature(features =>
{
features.AddFeature<ConsensusFeature>().FeatureServices(services =>
{
services.AddSingleton<DBreezeCoinView>();
services.AddSingleton<ICoinView, CachedCoinView>();
services.AddSingleton<ConsensusController>();
services.AddSingleton<IConsensusRuleEngine, SmartContractPoARuleEngine>();
services.AddSingleton<IChainState, ChainState>();
services.AddSingleton<ConsensusQuery>()
.AddSingleton<INetworkDifficulty, ConsensusQuery>(provider => provider.GetService<ConsensusQuery>())
.AddSingleton<IGetUnspentTransaction, ConsensusQuery>(provider => provider.GetService<ConsensusQuery>());
new SmartContractPoARuleRegistration(fullNodeBuilder.Network).RegisterRules(fullNodeBuilder.Network.Consensus);
});
});

return fullNodeBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public FederationGatewaySettings(NodeSettings nodeSettings)
if (!this.IsMainChain && !configReader.GetOrDefault("sidechain", false))
throw new ConfigurationException("Either -mainchain or -sidechain must be specified");

var redeemScriptRaw = configReader.GetOrDefault<string>(RedeemScriptParam, null);
string redeemScriptRaw = configReader.GetOrDefault<string>(RedeemScriptParam, null);
Console.WriteLine(redeemScriptRaw);
if (redeemScriptRaw == null)
throw new ConfigurationException($"could not find {RedeemScriptParam} configuration parameter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NBitcoin;
using Stratis.Bitcoin.Utilities;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using NBitcoin;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
using System.Net.Http;
using System.Threading.Tasks;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Stratis.Bitcoin.Utilities;
using Stratis.FederatedPeg.Features.FederationGateway.Models;
using Stratis.FederatedPeg.Features.FederationGateway.Models;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using NBitcoin;
using NBitcoin;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using NBitcoin;

namespace Stratis.FederatedPeg.Features.FederationGateway.Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using NBitcoin;
using Newtonsoft.Json;
using Stratis.Bitcoin.Features.Wallet.Models;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using Stratis.Bitcoin.Features.Wallet.Models;
using Stratis.FederatedPeg.Features.FederationGateway.Interfaces;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using NBitcoin;
using Stratis.Bitcoin.Features.Wallet.Interfaces;
using NBitcoin;
using Stratis.Bitcoin.Signals;
using Stratis.FederatedPeg.Features.FederationGateway.Interfaces;

Expand Down
Loading

0 comments on commit 1b4aa0c

Please sign in to comment.