/// <summary>
 /// Initializes a new instance of the <see cref="BlockFinder"/> class.
 /// </summary>
 public BlockFinder(NakoApplication application, NakoConfiguration config, ISyncOperations syncOperations, SyncConnection syncConnection, Tracer tracer)
     : base(application, config, tracer)
 {
     this.tracer         = tracer;
     this.syncConnection = syncConnection;
     this.syncOperations = syncOperations;
     this.config         = config;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PoolFinder"/> class.
 /// </summary>
 public PoolFinder(IOptions <NakoConfiguration> configuration, ISyncOperations syncOperations, SyncConnection syncConnection, ILogger <PoolFinder> logger)
     : base(configuration, logger)
 {
     this.log            = logger;
     this.syncConnection = syncConnection;
     this.syncOperations = syncOperations;
     this.config         = configuration.Value;
 }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SyncOperations"/> class.
        /// </summary>
        public SyncOperations(IStorage storage, ILogger <SyncOperations> logger, IOptions <NakoConfiguration> configuration)
        {
            this.configuration = configuration.Value;
            this.log           = logger;
            this.storage       = storage;

            // Register the cold staking template.
            StandardScripts.RegisterStandardScriptTemplate(ColdStakingScriptTemplate.Instance);
        }
 public MongoData(Tracer tracer, SyncConnection connection, NakoConfiguration nakoConfiguration)
 {
     this.syncConnection     = connection;
     this.tracer             = tracer;
     this.configuration      = nakoConfiguration;
     this.mongoClient        = new MongoClient(nakoConfiguration.ConnectionString);
     this.mongoDatabase      = this.mongoClient.GetDatabase("Blockchain");
     this.MemoryTransactions = new ConcurrentDictionary <string, DecodedRawTransaction>();
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Notifier"/> class.
 /// </summary>
 public Notifier(IOptions <NakoConfiguration> configuration, ILogger <Notifier> logger, IStorage storage)
     : base(configuration, logger)
 {
     this.configuration = configuration.Value;
     this.log           = logger;
     this.storage       = storage;
     this.client        = new Lazy <HttpClient>(() => new HttpClient(new HttpClientHandler {
         ServerCertificateCustomValidationCallback = (sender, certificate, chain, errors) => errors == SslPolicyErrors.None || errors == SslPolicyErrors.RemoteCertificateNameMismatch
     }));
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Notifier"/> class.
 /// </summary>
 public Notifier(NakoApplication application, NakoConfiguration config, Tracer tracer, IStorage storage)
     : base(application, config, tracer)
 {
     this.configuration = config;
     this.tracer        = tracer;
     this.storage       = storage;
     this.client        = new Lazy <HttpClient>(() => new HttpClient(new HttpClientHandler {
         ServerCertificateCustomValidationCallback = (sender, certificate, chain, errors) => errors == SslPolicyErrors.None || errors == SslPolicyErrors.RemoteCertificateNameMismatch
     }));
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SyncConnection"/> class.
 /// </summary>
 public SyncConnection(NakoConfiguration configuration)
 {
     this.CoinTag         = configuration.CoinTag;
     this.Password        = configuration.RpcPassword;
     this.RpcAccessPort   = configuration.RpcAccessPort;
     this.ServerDomain    = configuration.RpcDomain;
     this.User            = configuration.RpcUser;
     this.Secure          = configuration.RpcSecure;
     this.StartBlockIndex = configuration.StartBlockIndex;
 }
예제 #8
0
        public MongoData(ILogger <MongoStorageOperations> logger, SyncConnection connection, IOptions <NakoConfiguration> nakoConfiguration)
        {
            this.syncConnection = connection;
            this.log            = logger;
            this.configuration  = nakoConfiguration.Value;
            this.mongoClient    = new MongoClient(this.configuration.ConnectionStringActual);
            var dbName = this.configuration.DatabaseNameSubfix ? "Blockchain" + this.configuration.CoinTag : "Blockchain";

            this.mongoDatabase      = this.mongoClient.GetDatabase(dbName);
            this.MemoryTransactions = new ConcurrentDictionary <string, NBitcoin.Transaction>();
        }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoStorageOperations"/> class.
 /// </summary>
 public MongoStorageOperations(IStorage storage,
                               MongoData mongoData,
                               Tracer tracer,
                               NakoConfiguration nakoConfiguration,
                               SyncConnection syncConnection)
 {
     this.data           = mongoData;
     this.configuration  = nakoConfiguration;
     this.tracer         = tracer;
     this.storage        = storage;
     this.syncConnection = syncConnection;
 }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SyncConnection"/> class.
        /// </summary>
        public SyncConnection(IOptions <NakoConfiguration> config)
        {
            NakoConfiguration configuration = config.Value;

            this.CoinTag         = configuration.CoinTag;
            this.Password        = configuration.RpcPassword;
            this.RpcAccessPort   = configuration.RpcAccessPort;
            this.ServerDomain    = configuration.RpcDomainActual;
            this.User            = configuration.RpcUser;
            this.Secure          = configuration.RpcSecure;
            this.StartBlockIndex = configuration.StartBlockIndex;

            // This can be replaced with a specific the network class of a specific coin
            // Or use the config values to simulate the network class.
            this.Network = new NetworkConfig(config.Value);

            this.RecentItems = new Buffer <(DateTime Inserted, TimeSpan Duration, long Size)>(5000);
        }
예제 #11
0
        public NetworkConfig(NakoConfiguration config)
        {
            this.CoinTicker = config.CoinTag;

            ConsensusFactory consensusFactory = (ConsensusFactory)Activator.CreateInstance(Type.GetType(config.NetworkConsensusFactoryType));

            this.Consensus = new ConsensusConfig(config, consensusFactory);

            this.Base58Prefixes = new byte[12][];
            this.Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (config.NetworkPubkeyAddressPrefix) };
            this.Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (config.NetworkScriptAddressPrefix) };

            this.Bech32Encoders = new Bech32Encoder[2];
            var encoder = new Bech32Encoder(config.NetworkWitnessPrefix);

            this.Bech32Encoders[(int)Bech32Type.WITNESS_PUBKEY_ADDRESS] = encoder;
            this.Bech32Encoders[(int)Bech32Type.WITNESS_SCRIPT_ADDRESS] = encoder;

            // TODO
            //StandardScripts.RegisterStandardScriptTemplate(ColdStakingScriptTemplate);
        }
예제 #12
0
 public ConsensusConfig(NakoConfiguration config, ConsensusFactory consensusFactory) : base(
         consensusFactory: consensusFactory,
         consensusOptions: null,
         coinType: 0,
         hashGenesisBlock: uint256.Zero,
         subsidyHalvingInterval: 0,
         majorityEnforceBlockUpgrade: 0,
         majorityRejectBlockOutdated: 0,
         majorityWindow: 0,
         buriedDeployments: null,
         bip9Deployments: null,
         bip34Hash: uint256.Zero,
         ruleChangeActivationThreshold: 0,
         minerConfirmationWindow: 0,
         maxReorgLength: 0,
         defaultAssumeValid: uint256.Zero,
         maxMoney: 0,
         coinbaseMaturity: 0,
         premineHeight: 0,
         premineReward: 0,
         proofOfWorkReward: 0,
         powTargetTimespan: TimeSpan.Zero,
         powTargetSpacing: TimeSpan.Zero,
         powAllowMinDifficultyBlocks: false,
         posNoRetargeting: false,
         powNoRetargeting: false,
         powLimit: new Target(uint256.Zero),
         minimumChainWork: null,
         isProofOfStake: consensusFactory is PosConsensusFactory,
         lastPowBlock: 0,
         proofOfStakeLimit: null,
         proofOfStakeLimitV2: null,
         proofOfStakeReward: 0
         )
 {
 }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryHandler"/> class.
 /// </summary>
 public QueryHandler(NakoConfiguration configuration, IStorage storage)
 {
     this.storage       = storage;
     this.configuration = configuration;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SyncOperations"/> class.
 /// </summary>
 public SyncOperations(IStorage storage, Tracer tracer, NakoConfiguration nakoConfiguration)
 {
     this.configuration = nakoConfiguration;
     this.tracer        = tracer;
     this.storage       = storage;
 }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigureSwaggerOptions"/> class.
 /// </summary>
 /// <param name="provider">The <see cref="IApiVersionDescriptionProvider">provider</see> used to generate Swagger documents.</param>
 public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider, IOptions <NakoConfiguration> configuration)
 {
     this.provider      = provider;
     this.configuration = configuration.Value;
 }
예제 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StatsHandler"/> class.
 /// </summary>
 public StatsHandler(SyncConnection connection, IStorage storage, IOptions <NakoConfiguration> configuration)
 {
     this.storage        = storage;
     this.syncConnection = connection;
     this.configuration  = configuration.Value;
 }
예제 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskRunner"/> class.
 /// </summary>
 protected TaskRunner(NakoApplication application, NakoConfiguration configuration, Tracer tracer)
 {
     this.tracer      = tracer;
     this.application = application;
     this.Delay       = TimeSpan.FromSeconds(configuration.SyncInterval);
 }
예제 #18
0
파일: ApiServer.cs 프로젝트: wtcoin/Nako
 //// This code configures Web API. The ApiServer class is specified as a type
 //// parameter in the WebApp.Start method.
 public ApiServer(NakoApplication nakoApplication, NakoConfiguration nakoConfiguration, Tracer tracer)
 {
     this.configuration = nakoConfiguration;
     this.tracer        = tracer;
     this.application   = nakoApplication;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskRunner{T}"/> class.
 /// </summary>
 protected TaskRunner(NakoApplication application, NakoConfiguration config, Tracer tracer)
     : base(application, config, tracer)
 {
     this.Queue = new ConcurrentQueue <T>();
 }
예제 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlockStore"/> class.
 /// </summary>
 public BlockStore(NakoApplication application, NakoConfiguration config, Tracer tracer, IStorageOperations storageOperations)
     : base(application, config, tracer)
 {
     this.storageOperations = storageOperations;
     this.tracer            = tracer;
 }
예제 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryHandler"/> class.
 /// </summary>
 public QueryHandler(IOptions <NakoConfiguration> configuration, IStorage storage)
 {
     this.storage       = storage;
     this.configuration = configuration.Value;
 }
예제 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SyncServer"/> class.
 /// </summary>
 public SyncServer(ILogger <SyncServer> logger, IOptions <NakoConfiguration> configuration, IServiceScopeFactory scopeFactory)
 {
     this.log           = logger;
     this.configuration = configuration.Value;
     this.scopeFactory  = scopeFactory;
 }