/// <summary> /// Adds a watch only wallet component to the node being initialized. /// </summary> /// <param name="fullNodeBuilder">The object used to build the current node.</param> /// <returns>The full node builder, enriched with the new component.</returns> public static IFullNodeBuilder UseWatchOnlyWallet(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <WatchOnlyWalletFeature>() .DependOn <BlockNotificationFeature>() .DependOn <TransactionNotificationFeature>() .FeatureServices(services => { services.AddSingleton <IWatchOnlyWalletManager, WatchOnlyWalletManager>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder AddInteroperability(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <InteropFeature>("interop"); fullNodeBuilder.ConfigureFeature(features => features .AddFeature <InteropFeature>() .FeatureServices(services => services .AddSingleton <InteropSettings>() .AddSingleton <IEthereumClientBase, EthereumClientBase>() .AddSingleton <IInteropTransactionManager, InteropTransactionManager>() .AddSingleton <InteropPoller>() )); return(fullNodeBuilder); }
public static IFullNodeBuilder UseTransactionNotification(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <TransactionNotificationFeature>() .FeatureServices(services => { services.AddSingleton <TransactionNotificationProgress>(); services.AddSingleton <TransactionNotification>(); services.AddSingleton <TransactionReceiver>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder AddPowPosMining(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <MiningFeature>() .FeatureServices(services => { services.AddSingleton <PowMining>(); services.AddSingleton <PosMinting>(); services.AddSingleton <AssemblerFactory, PosAssemblerFactory>(); }); }); return(fullNodeBuilder); }
/// <summary>Adds Proof-of-Authority mining to the side chain node.</summary> /// <typeparam name="T">The type of block definition to use.</typeparam> public static IFullNodeBuilder AddPoAMiningCapability <T>(this IFullNodeBuilder fullNodeBuilder) where T : BlockDefinition { fullNodeBuilder.ConfigureFeature(features => { IFeatureRegistration feature = fullNodeBuilder.Features.FeatureRegistrations.FirstOrDefault(f => f.FeatureType == typeof(PoAFeature)); feature.FeatureServices(services => { services.AddSingleton <IPoAMiner, PoAMiner>(); services.AddSingleton <MinerSettings>(); services.AddSingleton <BlockDefinition, T>(); services.AddSingleton <IBlockBufferGenerator, BlockBufferGenerator>(); }); }); return(fullNodeBuilder); }
/// <summary> /// Adds a feature to the node that will allow secertain services to be overridden. /// </summary> /// <param name="fullNodeBuilder">The object used to build the current node.</param> /// <param name="serviceToOverride">Callback routine that will override a given service.</param> /// <typeparam name="T">The feature that the service will be replaced in.</typeparam> /// <returns>The full node builder, enriched with the new component.</returns> public static IFullNodeBuilder OverrideService <T>(this IFullNodeBuilder fullNodeBuilder, Action <IServiceCollection> serviceToOverride) { fullNodeBuilder.ConfigureFeature(features => { IFeatureRegistration feature = features.FeatureRegistrations.FirstOrDefault(f => f.FeatureType == typeof(T)); if (feature != null) { feature.FeatureServices(services => { serviceToOverride(services); }); } }); return(fullNodeBuilder); }
/// <summary> /// Adds a feature to the node that will allow certain services to be overridden. /// </summary> /// <param name="fullNodeBuilder">The object used to build the current node.</param> /// <typeparam name="TFeature">The feature that the service should be added to.</typeparam> /// <typeparam name="T">The serice to add.</typeparam> /// <returns>The full node builder, enriched with the new component.</returns> public static IFullNodeBuilder AddService <TFeature, T>(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { IFeatureRegistration feature = features.FeatureRegistrations.FirstOrDefault(f => f.FeatureType == typeof(TFeature)); if (feature != null) { feature.FeatureServices(services => { services.AddSingleton(typeof(T)); }); } }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseBlockNotification(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <BlockNotificationFeature>() .FeatureServices(services => { services.AddSingleton <IBlockNotification, BlockNotification>(); services.AddSingleton <LookaheadBlockPuller>().AddSingleton <ILookaheadBlockPuller, LookaheadBlockPuller>(provider => provider.GetService <LookaheadBlockPuller>()); services.AddSingleton <NotificationsController>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseWallet(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <WalletFeature>() .FeatureServices(services => { services.AddTransient <IWalletWrapper, WalletWrapper>(); services.AddTransient <ITrackerWrapper, TrackerWrapper>(); services.AddSingleton <WalletController>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseWallet(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <WalletFeature>() .FeatureServices(services => { services.AddSingleton <IWalletSyncManager, WalletSyncManager>(); services.AddSingleton <IWalletManager, WalletManager>(); services.AddSingleton <WalletController>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseDiagnosticFeature(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <DiagnosticFeature>("diagnostic"); fullNodeBuilder.ConfigureFeature(features => features .AddFeature <DiagnosticFeature>() .FeatureServices(services => services .AddSingleton <DiagnosticController>() .AddSingleton <PeerStatisticsCollector>() .AddSingleton <DiagnosticSettings>() ) ); return(fullNodeBuilder); }
public static IFullNodeBuilder UsexServer(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <xServerFeature>("xserver"); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <xServerFeature>() .FeatureServices(services => { services.AddSingleton <xServerSettings>(); services.AddSingleton <IxServerManager, xServerManager>(); }); }); return(fullNodeBuilder); }
/// <summary> /// Makes the full node use all the required features - <see cref="BaseFeature"/>. /// </summary> /// <param name="fullNodeBuilder">Builder responsible for creating the node.</param> /// <returns>Full node builder's interface to allow fluent code.</returns> public static IFullNodeBuilder UseBaseFeature(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <BaseFeature>() .FeatureServices(services => { services.AddSingleton <DBreezeSerializer>(); services.AddSingleton(fullNodeBuilder.NodeSettings.LoggerFactory); services.AddSingleton(fullNodeBuilder.NodeSettings.DataFolder); services.AddSingleton <INodeLifetime, NodeLifetime>(); services.AddSingleton <IPeerBanning, PeerBanning>(); services.AddSingleton <FullNodeFeatureExecutor>(); services.AddSingleton <Signals.Signals>().AddSingleton <ISignals, Signals.Signals>(provider => provider.GetService <Signals.Signals>()); services.AddSingleton <FullNode>().AddSingleton((provider) => { return(provider.GetService <FullNode>() as IFullNode); }); services.AddSingleton <ConcurrentChain>(new ConcurrentChain(fullNodeBuilder.Network)); services.AddSingleton <IDateTimeProvider>(DateTimeProvider.Default); services.AddSingleton <IInvalidBlockHashStore, InvalidBlockHashStore>(); services.AddSingleton <IChainState, ChainState>(); services.AddSingleton <IChainRepository, ChainRepository>().AddSingleton <IFinalizedBlockHeight, ChainRepository>(provider => provider.GetService <IChainRepository>() as ChainRepository); services.AddSingleton <ITimeSyncBehaviorState, TimeSyncBehaviorState>(); services.AddSingleton <IAsyncLoopFactory, AsyncLoopFactory>(); services.AddSingleton <NodeDeployments>(); // Connection services.AddSingleton <INetworkPeerFactory, NetworkPeerFactory>(); services.AddSingleton <NetworkPeerConnectionParameters>(new NetworkPeerConnectionParameters()); services.AddSingleton <IConnectionManager, ConnectionManager>(); services.AddSingleton <ConnectionManagerSettings>(); services.AddSingleton <PayloadProvider>(new PayloadProvider().DiscoverPayloads()); services.AddSingleton <BestChainSelector>(); services.AddSingleton <IVersionProvider, VersionProvider>(); // Peer address manager services.AddSingleton <IPeerAddressManager, PeerAddressManager>(); services.AddSingleton <IPeerConnector, PeerConnectorAddNode>(); services.AddSingleton <IPeerConnector, PeerConnectorConnectNode>(); services.AddSingleton <IPeerConnector, PeerConnectorDiscovery>(); services.AddSingleton <IPeerDiscovery, PeerDiscovery>(); services.AddSingleton <ISelfEndpointTracker, SelfEndpointTracker>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder AddRPC(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <RPCFeature>() .FeatureServices(services => services.AddSingleton(fullNodeBuilder)); }); fullNodeBuilder.ConfigureServices(service => { service.AddSingleton <FullNodeController>(); service.AddSingleton <ConnectionManagerController>(); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseX1WalletApi(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <X1WalletApiFeature>(nameof(X1WalletApiFeature)); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <X1WalletApiFeature>() .DependOn <X1WalletFeature>() .FeatureServices(services => { services.AddTransient <SecureApiController>(); }); }); return(fullNodeBuilder); }
/// <summary> /// Adds chain Interoperability to the node. /// </summary> /// <param name="fullNodeBuilder">The full node builder instance.</param> public static IFullNodeBuilder AddInteroperability(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <InteropFeature>("interop"); fullNodeBuilder.ConfigureFeature(features => features .AddFeature <InteropFeature>() .FeatureServices(services => services .AddSingleton <InteropSettings>() .AddSingleton <IETHClient, ETHClient.ETHClient>() .AddSingleton <IBNBClient, BNBClient>() .AddSingleton <IETHCompatibleClientProvider, ETHCompatibleClientProvider>() .AddSingleton <InteropPoller>() )); return(fullNodeBuilder); }
public static IFullNodeBuilder UseAzureIndexer(this IFullNodeBuilder fullNodeBuilder, Action <AzureIndexerSettings> setup = null) { LoggingConfiguration.RegisterFeatureNamespace <AzureIndexerFeature>("azindex"); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <AzureIndexerFeature>() .FeatureServices(services => { services.AddSingleton <AzureIndexerLoop>(); services.AddSingleton <AzureIndexerSettings>(new AzureIndexerSettings(setup)); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseBlockNotification(this IFullNodeBuilder fullNodeBuilder, uint256 startHash) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <BlockNotificationFeature>() .FeatureServices(services => { services.AddSingleton(new BlockNotificationStartHash(startHash)); services.AddSingleton <BlockNotification>(); services.AddSingleton <Signals>(); services.AddSingleton <BlockPuller, LookaheadBlockPuller>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseApps(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <AppsFeature>("apps"); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <AppsFeature>() .FeatureServices(services => { services.AddSingleton <IAppsStore, AppsStore>(); services.AddSingleton <IAppsHost, AppsHost>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseNodeHost(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <NodeHostFeature>() .FeatureServices(services => { services.AddSingleton(fullNodeBuilder); services.AddSingleton <NodeHostSettings>(); services.AddSingleton <IEventsSubscriptionService, EventSubscriptionService>(); services.AddSingleton <ICertificateStore, CertificateStore>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder AddMining(this IFullNodeBuilder fullNodeBuilder, bool doMining) { if (doMining) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <MiningFeature>() .FeatureServices(services => { services.AddSingleton <Mining>(); }); }); } return(fullNodeBuilder); }
/// <summary> /// Adds the smart contract feature to the node. /// </summary> public static IFullNodeBuilder AddSmartContracts(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <SmartContractFeature>("smartcontracts"); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <SmartContractFeature>() .FeatureServices(services => { // STATE ---------------------------------------------------------------------------- services.AddSingleton <DBreezeContractStateStore>(); services.AddSingleton <NoDeleteContractStateSource>(); services.AddSingleton <IStateRepositoryRoot, StateRepositoryRoot>(); // CONSENSUS ------------------------------------------------------------------------ services.AddSingleton <IMempoolValidator, SmartContractMempoolValidator>(); services.AddSingleton <StandardTransactionPolicy, SmartContractTransactionPolicy>(); // CONTRACT EXECUTION --------------------------------------------------------------- services.AddSingleton <IInternalExecutorFactory, InternalExecutorFactory>(); services.AddSingleton <IVirtualMachine, ReflectionVirtualMachine>(); services.AddSingleton <IAddressGenerator, AddressGenerator>(); services.AddSingleton <ILoader, ContractAssemblyLoader>(); services.AddSingleton <IContractModuleDefinitionReader, ContractModuleDefinitionReader>(); services.AddSingleton <IStateFactory, StateFactory>(); services.AddSingleton <SmartContractTransactionPolicy>(); services.AddSingleton <IStateProcessor, StateProcessor>(); services.AddSingleton <ISmartContractStateFactory, SmartContractStateFactory>(); // RECEIPTS ------------------------------------------------------------------------- services.AddSingleton <IReceiptRepository, PersistentReceiptRepository>(); // UTILS ---------------------------------------------------------------------------- services.AddSingleton <ISenderRetriever, SenderRetriever>(); services.AddSingleton <IVersionProvider, SmartContractVersionProvider>(); ICallDataSerializer callDataSerializer = CallDataSerializer.Default; services.AddSingleton(callDataSerializer); services.Replace(new ServiceDescriptor(typeof(IScriptAddressReader), new SmartContractScriptAddressReader(new ScriptAddressReader(), callDataSerializer))); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseBlockExplorer(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <BlockExplorerFeature>("db"); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <BlockExplorerFeature>() .DependOn <BlockStoreFeature>() .FeatureServices(services => { services.AddSingleton <BlockExplorerController>(); services.AddSingleton <TransactionStoreController>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder AddMining(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <MiningFeature>("mining"); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <MiningFeature>() .FeatureServices(services => { services.AddSingleton <PowMining>(); services.AddSingleton <AssemblerFactory, PowAssemblerFactory>(); services.AddSingleton <MiningRPCController>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder CheckForPoAMembersCollateral(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features.AddFeature <CollateralFeature>() .DependOn <CounterChainFeature>() .DependOn <PoAFeature>() .FeatureServices(services => { services.AddSingleton <IFederationManager, CollateralFederationManager>(); services.AddSingleton <ICollateralChecker, CollateralChecker>(); new SmartContractCollateralPoARuleRegistration().RegisterRules(services); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseTestFedPegBlockDefinition(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { foreach (IFeatureRegistration feature in features.FeatureRegistrations) { feature.FeatureServices(services => { ServiceDescriptor cht = services.FirstOrDefault(x => x.ServiceType == typeof(BlockDefinition)); services.Remove(cht); services.AddSingleton <BlockDefinition, TestFederatedPegBlockDefinition>(); }); } }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseConsensus(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <ConsensusFeature>() .FeatureServices(services => { services.AddSingleton(new ConsensusValidator(fullNodeBuilder.Network.Consensus)); services.AddSingleton <DBreezeCoinView>(); services.AddSingleton <CoinView, CachedCoinView>(); services.AddSingleton <LookaheadBlockPuller>(); services.AddSingleton <ConsensusLoop>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder UseLightWallet(this IFullNodeBuilder fullNodeBuilder) { fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <LightWalletFeature>() .FeatureServices(services => { services.AddSingleton <IWalletSyncManager, LightWalletSyncManager>(); services.AddSingleton <IWalletTransactionHandler, WalletTransactionHandler>(); services.AddSingleton <IWalletManager, WalletManager>(); services.AddSingleton <IWalletFeePolicy, LightWalletFeePolicy>(); services.AddSingleton <WalletController>(); }); }); return(fullNodeBuilder); }
public static IFullNodeBuilder ReplaceTimeProvider(this IFullNodeBuilder fullNodeBuilder, IDateTimeProvider timeProvider) { fullNodeBuilder.ConfigureFeature(features => { foreach (IFeatureRegistration feature in features.FeatureRegistrations) { feature.FeatureServices(services => { ServiceDescriptor defaultProivider = services.FirstOrDefault(x => x.ServiceType == typeof(IDateTimeProvider)); services.Remove(defaultProivider); services.AddSingleton <IDateTimeProvider>(provider => timeProvider); }); } }); return(fullNodeBuilder); }
public static IFullNodeBuilder AddFederationGateway(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <FederationGatewayFeature>( FederationGatewayFeature.FederationGatewayFeatureNamespace); fullNodeBuilder.ConfigureFeature( features => { 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>(); }); }); return(fullNodeBuilder); }