public MigrationManager(IMySqlProvider provider, IPoolConfig poolConfig) { _provider = provider; _logger = Log.ForContext <MigrationManager>().ForContext("Component", poolConfig.Coin.Name); Check(); }
public BlockProcessorTests() { // create mockup objects required for tests. _daemonClient = Substitute.For<IDaemonClient>(); _poolConfig = Substitute.For<IPoolConfig>(); _storageLayer = Substitute.For<IStorageLayer>(); }
public MigrationManager(IMySqlProvider provider, IPoolConfig poolConfig) { _provider = provider; _logger = Log.ForContext<MigrationManager>().ForContext("Component", poolConfig.Coin.Name); Check(); }
public PaymentProcessor(IPoolConfig poolConfig, IStorageLayer storageLayer, IDaemonClient daemonClient, IAccountManager accountManager) { _poolConfig = poolConfig; _storageLayer = storageLayer; _daemonClient = daemonClient; _accountManager = accountManager; _logger = Log.ForContext <PaymentProcessor>().ForContext("Component", poolConfig.Coin.Name); if (!_poolConfig.Payments.Enabled) // make sure payments are enabled. { return; } if (!ValidatePoolAddress()) // try to validate the pool wallet. { return; // if we can't, stop the payment processor. } if (!GetPoolAccount()) // get the pool's account name if any. { return; // if we can't, stop the payment processor. } FindPoolZAddress(); Active = true; }
/// <summary> /// Initializes a new instance of the <see cref="Pool" /> class. /// </summary> /// <param name="poolConfig"></param> /// <param name="configManager"></param> /// <param name="objectFactory"></param> public Pool(IPoolConfig poolConfig, IConfigManager configManager, IObjectFactory objectFactory) { Enforce.ArgumentNotNull(() => poolConfig); // make sure we have a pool-config instance supplied. Enforce.ArgumentNotNull(() => configManager); // make sure we have a config-manager instance supplied. Enforce.ArgumentNotNull(() => objectFactory); // make sure we have a objectFactory instance supplied. // TODO: validate pool central wallet & rewards within the startup. _configManager = configManager; _objectFactory = objectFactory; Config = poolConfig; _logger = Log.ForContext <Pool>().ForContext("Component", Config.Coin.Name); GenerateInstanceId(); // generate unique instance id for the pool. try { InitDaemon(); // init coin daemon. InitStorage(); // init storage support. InitManagers(); // init managers. InitServers(); // init servers. Enabled = true; } catch (Exception e) { _logger.Error("Error initializing pool; {0:l}", e); Enabled = false; } }
public VanillaServer(IPoolConfig poolConfig, IPool pool, IMinerManager minerManager, IJobManager jobManager) { _pool = pool; _minerManager = minerManager; _jobManager = jobManager; _logger = Log.ForContext <VanillaServer>().ForContext("Component", poolConfig.Coin.Name); }
public BlockProcessorTests() { // create mockup objects required for tests. _daemonClient = Substitute.For <IDaemonClient>(); _poolConfig = Substitute.For <IPoolConfig>(); _storageLayer = Substitute.For <IStorageLayer>(); }
public IPool AddPool(IPoolConfig poolConfig) { var pool = _poolFactory.Create(poolConfig); _pools.Add(pool); return pool; }
public MinerManager(IPoolConfig poolConfig, IStorageLayer storageLayer) { _poolConfig = poolConfig; _storageLayer = storageLayer; _miners = new Dictionary <int, IMiner>(); _logger = Log.ForContext <MinerManager>().ForContext("Component", poolConfig.Coin.Name); }
public StratumServiceTests() { _shareManager = Substitute.For<IShareManager>(); _poolConfig = Substitute.For<IPoolConfig>(); var miner = Substitute.For<IStratumMiner>(); _stratumContext = Substitute.For<StratumContext>(miner); }
/// <summary> /// Initializes a new instance of the <see cref="StratumServer"/> class. /// </summary> /// <param name="pool"></param> /// <param name="minerManager">The miner manager.</param> /// <param name="jobManager"></param> /// <param name="banManager"></param> /// <param name="poolConfig"></param> public StratumServer(IPoolConfig poolConfig, IPool pool, IMinerManager minerManager, IJobManager jobManager, IBanManager banManager) { _pool = pool; _minerManager = minerManager; _jobManager = jobManager; _banManager = banManager; _logger = Log.ForContext <StratumServer>().ForContext("Component", poolConfig.Coin.Name); }
public MySqlProvider(IPoolConfig poolConfig, IMySqlProviderConfig config) { _logger = Log.ForContext <MySqlProvider>().ForContext("Component", poolConfig.Coin.Name); _config = config; Initialize(); }
public StratumService(IPoolConfig poolConfig, IShareManager shareManager) : base(poolConfig.Coin.Name) { _submitFrequency = 0; _submitCounter = 1; _shareManager = shareManager; _poolConfig = poolConfig; }
public BlockProcessor(IPoolConfig poolConfig, IDaemonClient daemonClient) { _poolConfig = poolConfig; _daemonClient = daemonClient; _logger = Log.ForContext <BlockProcessor>().ForContext("Component", poolConfig.Coin.Name); FindPoolAccount(); }
public DaemonBase(IPoolConfig poolConfig) { RpcUrl = string.Format("http://{0}:{1}", poolConfig.Daemon.Host, poolConfig.Daemon.Port); RpcUser = poolConfig.Daemon.Username; RpcPassword = poolConfig.Daemon.Password; RequestCounter = 0; _logger = LogManager.PacketLogger.ForContext <DaemonClient>().ForContext("Component", poolConfig.Coin.Name); }
/// <summary> /// Initializes a new instance of the <see cref="StratumServer"/> class. /// </summary> /// <param name="pool"></param> /// <param name="minerManager">The miner manager.</param> /// <param name="jobManager"></param> /// <param name="banManager"></param> /// <param name="poolConfig"></param> public StratumServer(IPoolConfig poolConfig, IPool pool, IMinerManager minerManager, IJobManager jobManager, IBanManager banManager) { _pool = pool; _minerManager = minerManager; _jobManager = jobManager; _banManager = banManager; _logger = Log.ForContext<StratumServer>().ForContext("Component", poolConfig.Coin.Name); }
public RedisProvider(IPoolConfig poolConfig, IRedisProviderConfig config) { _logger = Log.ForContext<RedisProvider>().ForContext("Component", poolConfig.Coin.Name); _config = config; Initialize(); }
/// <summary> /// Creates a new instance of generation transaction. /// </summary> /// <param name="extraNonce">The extra nonce.</param> /// <param name="daemonClient">The daemon client.</param> /// <param name="blockTemplate">The block template.</param> /// <param name="poolConfig">The associated pool's configuration</param> /// <remarks> /// Reference implementations: /// https://github.com/zone117x/node-stratum-pool/blob/b24151729d77e0439e092fe3a1cdbba71ca5d12e/lib/transactions.js /// https://github.com/Crypto-Expert/stratum-mining/blob/master/lib/coinbasetx.py /// </remarks> public GenerationTransaction(IExtraNonce extraNonce, IDaemonClient daemonClient, IBlockTemplate blockTemplate, IPoolConfig poolConfig) { // TODO: we need a whole refactoring here. // we should use DI and it shouldn't really require daemonClient connection to function. BlockTemplate = blockTemplate; ExtraNonce = extraNonce; PoolConfig = poolConfig; Version = 1;//change version for bitcoin like TxMessage = Serializers.SerializeString(poolConfig.Meta.TxMessage); LockTime = 0; // transaction inputs Inputs = new List <TxIn> { new TxIn { PreviousOutput = new OutPoint { Hash = Hash.ZeroHash, Index = (UInt32)Math.Pow(2, 32) - 1 }, Sequence = (UInt32)Math.Pow(2, 32) - 1, SignatureScript = new SignatureScript( blockTemplate.Height, //blockTemplate.CoinBaseAux.Flags, "", TimeHelpers.NowInUnixTimestamp(), (byte)extraNonce.ExtraNoncePlaceholder.Length, "") } }; // transaction outputs Outputs = new Outputs(daemonClient, poolConfig.Coin); double blockReward = BlockTemplate.Coinbasevalue; // the amount rewarded by the block. // generate output transactions for recipients (set in config). /*foreach (var pair in poolConfig.Rewards) * { * var amount = blockReward * pair.Value / 100; // calculate the amount he recieves based on the percent of his shares. * blockReward -= amount; * * Outputs.AddRecipient(pair.Key, amount); * }*/ // send the remaining coins to pool's central wallet. Outputs.AddPoolWallet(poolConfig.Wallet.Adress, blockReward); }
public IStorage GetStorage(string type, IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig } }; return(_applicationContext.Container.Resolve <IStorage>(type, @params)); }
/// <summary> /// Initializes a new instance of the <see cref="ShareManager" /> class. /// </summary> /// <param name="poolConfig"></param> /// <param name="daemonClient"></param> /// <param name="jobTracker"></param> /// <param name="storageLayer"></param> /// <param name="blockProcessor"></param> public ShareManager(IPoolConfig poolConfig, IDaemonClient daemonClient, IJobTracker jobTracker, IStorageLayer storageLayer, IBlockProcessor blockProcessor) { _poolConfig = poolConfig; _daemonClient = daemonClient; _jobTracker = jobTracker; _storageLayer = storageLayer; _blockProcessor = blockProcessor; _logger = Log.ForContext <ShareManager>().ForContext("Component", poolConfig.Coin.Name); }
public PaymentProcessor(IPoolConfig poolConfig, IStorageLayer storageLayer, IDaemonClient daemonClient, IBlockProcessor blockProcessor) { _poolConfig = poolConfig; _daemonClient = daemonClient; _storageLayer = storageLayer; _blockProcessor = blockProcessor; _logger = Log.ForContext <PaymentProcessor>().ForContext("Component", poolConfig.Coin.Name); }
private readonly int _cleanupFrequency; // frequency to cleanup jobs in seconds. public JobTracker(IPoolConfig poolConfig) { _jobs = new Dictionary <UInt64, IJob>(); _logger = Log.ForContext <JobTracker>().ForContext("Component", poolConfig.Coin.Name); _cleanupFrequency = MinimumJobBacklog * poolConfig.Job.RebroadcastTimeout; // calculate the cleanup frequency = number of jobs in backlog * rebroad-timeout _cleanupTimer = new Timer(CleanUp, null, Timeout.Infinite, Timeout.Infinite); // create the timer as disabled. _cleanupTimer.Change(_cleanupFrequency * 1000, Timeout.Infinite); // adjust the timer's next run. }
public ProfitInfo(IMarketManager marketManager, INetworkInfo networkInfo, IPoolConfig poolConfig) { _logger = Log.ForContext <ProfitInfo>().ForContext("Component", poolConfig.Coin.Name); _poolConfig = poolConfig; _networkInfo = networkInfo; _marketManager = marketManager; _marketManager.Update += OnMarketUpdate; }
/// <summary> /// Returns a new instance of daemon client. /// </summary> /// <returns></returns> public IDaemonClient GetDaemonClient(IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig } }; return(_applicationContext.Container.Resolve <IDaemonClient>(@params)); }
public ProfitInfo(IMarketManager marketManager, INetworkInfo networkInfo, IPoolConfig poolConfig) { _logger = Log.ForContext<ProfitInfo>().ForContext("Component", poolConfig.Coin.Name); _poolConfig = poolConfig; _networkInfo = networkInfo; _marketManager = marketManager; _marketManager.Update += OnMarketUpdate; }
private readonly int _cleanupFrequency; // frequency to cleanup jobs in seconds. public JobTracker(IPoolConfig poolConfig) { _jobs = new Dictionary<UInt64, IJob>(); _logger = Log.ForContext<JobTracker>().ForContext("Component", poolConfig.Coin.Name); _cleanupFrequency = MinimumJobBacklog*poolConfig.Job.RebroadcastTimeout; // calculate the cleanup frequency = number of jobs in backlog * rebroad-timeout _cleanupTimer = new Timer(CleanUp, null, Timeout.Infinite, Timeout.Infinite); // create the timer as disabled. _cleanupTimer.Change(_cleanupFrequency * 1000, Timeout.Infinite); // adjust the timer's next run. }
public StratumServiceTests() { _shareManager = Substitute.For <IShareManager>(); _poolConfig = Substitute.For <IPoolConfig>(); var miner = Substitute.For <IStratumMiner>(); _stratumContext = Substitute.For <StratumContext>(miner); }
public IJobTracker GetJobTracker(IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig }, }; return(_applicationContext.Container.Resolve <IJobTracker>(@params)); }
/// <summary> /// Creates a new instance of generation transaction. /// </summary> /// <param name="extraNonce">The extra nonce.</param> /// <param name="daemonClient">The daemon client.</param> /// <param name="blockTemplate">The block template.</param> /// <param name="poolConfig">The associated pool's configuration</param> /// <remarks> /// Reference implementations: /// https://github.com/zone117x/node-stratum-pool/blob/b24151729d77e0439e092fe3a1cdbba71ca5d12e/lib/transactions.js /// https://github.com/Crypto-Expert/stratum-mining/blob/master/lib/coinbasetx.py /// </remarks> public GenerationTransaction(IExtraNonce extraNonce, IDaemonClient daemonClient, IBlockTemplate blockTemplate, IPoolConfig poolConfig) { // TODO: we need a whole refactoring here. // we should use DI and it shouldn't really require daemonClient connection to function. BlockTemplate = blockTemplate; ExtraNonce = extraNonce; PoolConfig = poolConfig; Version = blockTemplate.Version; TxMessage = Serializers.SerializeString(poolConfig.Meta.TxMessage); LockTime = 0; // transaction inputs Inputs = new List <TxIn> { new TxIn { PreviousOutput = new OutPoint { Hash = Hash.ZeroHash, Index = (UInt32)Math.Pow(2, 32) - 1 }, Sequence = 0x0, SignatureScript = new SignatureScript( blockTemplate.Height, blockTemplate.CoinBaseAux.Flags, TimeHelpers.NowInUnixTimestamp(), (byte)extraNonce.ExtraNoncePlaceholder.Length, "/CoiniumServ/") } }; // transaction outputs Outputs = new Outputs(daemonClient, poolConfig.Coin); double blockReward = BlockTemplate.Coinbasevalue; // the amount rewarded by the block. // generate output transactions for recipients (set in config). foreach (var pair in poolConfig.Rewards) { var amount = blockReward * pair.Value / 100; // calculate the amount the recieves based on the percent of his shares. blockReward -= amount; Outputs.AddRecipient(pair.Key, amount); } // send the remaining coins to pool's central wallet. Outputs.AddPoolWallet(poolConfig.Wallet.Adress, blockReward); // Final output is witness //https://github.com/slush0/stratum-mining/pull/16/files?diff=unified if (!string.IsNullOrEmpty(BlockTemplate.Default_witness_commitment)) { Outputs.AddWitnessOutput(BlockTemplate.Default_witness_commitment.HexToByteArray()); } }
/// <summary> /// Initializes a new instance of the <see cref="ShareManager" /> class. /// </summary> /// <param name="poolConfig"></param> /// <param name="daemonClient"></param> /// <param name="jobTracker"></param> /// <param name="storageLayer"></param> public ShareManager(IPoolConfig poolConfig, IDaemonClient daemonClient, IJobTracker jobTracker, IStorageLayer storageLayer) { _poolConfig = poolConfig; _daemonClient = daemonClient; _jobTracker = jobTracker; _storageLayer = storageLayer; _logger = Log.ForContext <ShareManager>().ForContext("Component", poolConfig.Coin.Name); FindPoolAccount(); }
public IMigrationManager GetMigrationManager(IMySqlProvider provider, IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { { "provider", provider }, { "poolConfig", poolConfig }, }; return(_applicationContext.Container.Resolve <IMigrationManager>(@params)); }
/// <summary> /// Initializes a new instance of the <see cref="ShareManager" /> class. /// </summary> /// <param name="poolConfig"></param> /// <param name="daemonClient"></param> /// <param name="jobTracker"></param> /// <param name="storageLayer"></param> public ShareManager(IPoolConfig poolConfig, IDaemonClient daemonClient, IJobTracker jobTracker, IStorageLayer storageLayer) { _poolConfig = poolConfig; _daemonClient = daemonClient; _jobTracker = jobTracker; _storageLayer = storageLayer; _logger = Log.ForContext<ShareManager>().ForContext("Component", poolConfig.Coin.Name); FindPoolAccount(); }
public MinerManager(IPoolConfig poolConfig, IStorageLayer storageLayer, IAccountManager accountManager, IDaemonClient daemonClient) { _poolConfig = poolConfig; _storageLayer = storageLayer; _accountManager = accountManager; _daemonClient = daemonClient; _miners = new Dictionary <int, IMiner>(); _logger = Log.ForContext <MinerManager>().ForContext("Component", poolConfig.Coin.Name); }
public IProfitInfo GetProfitInfo(INetworkInfo networkInfo, IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig }, { "networkInfo", networkInfo }, }; return(_applicationContext.Container.Resolve <IProfitInfo>(@params)); }
public MinerManager(IPoolConfig poolConfig, IDaemonClient daemonClient) { _minerConfig = poolConfig.Miner; _metaConfig = poolConfig.Meta; _daemonClient = daemonClient; _stratumServerConfig = poolConfig.Stratum; _miners = new Dictionary <int, IMiner>(); _logger = Log.ForContext <MinerManager>().ForContext("Component", poolConfig.Coin.Name); }
public IBlockProcessor GetBlockProcessor(IPoolConfig poolConfig, IDaemonClient daemonClient) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig }, { "daemonClient", daemonClient }, }; return(_applicationContext.Container.Resolve <IBlockProcessor>(@params)); }
public IVardiffManager GetVardiffManager(IPoolConfig poolConfig, IShareManager shareManager) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig }, { "shareManager", shareManager }, }; return(_applicationContext.Container.Resolve <IVardiffManager>(@params)); }
public IAccountManager GetAccountManager(IStorageLayer storageLayer, IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { { "storageLayer", storageLayer }, { "poolConfig", poolConfig }, }; return(_applicationContext.Container.Resolve <IAccountManager>(@params)); }
public IStorageProvider GetStorageProvider(string type, IPoolConfig poolConfig, IStorageProviderConfig config) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig }, { "config", config } }; return(_applicationContext.Container.Resolve <IStorageProvider>(type, @params)); }
public PerPool(IPoolConfig poolConfig, IDaemonClient daemonClient,IMinerManager minerManager, IHashAlgorithm hashAlgorithm, IBlocks blockStatistics, IStorage storage) { Config = poolConfig; _daemonClient = daemonClient; _minerManager = minerManager; Blocks = blockStatistics; _storage = storage; _response = new ExpandoObject(); _shareMultiplier = Math.Pow(2, 32) / hashAlgorithm.Multiplier; }
public BlockProcessor(IPoolConfig poolConfig, IDaemonClient daemonClient, IStorageLayer storageLayer) { _poolConfig = poolConfig; _daemonClient = daemonClient; _storageLayer = storageLayer; _logger = Log.ForContext<BlockProcessor>().ForContext("Component", poolConfig.Coin.Name); FindPoolAccount(); Active = true; }
public NetworkInfo(IDaemonClient daemonClient, IHashAlgorithm hashAlgorithm, IPoolConfig poolConfig) { _daemonClient = daemonClient; _hashAlgorithm = hashAlgorithm; _poolConfig = poolConfig; _logger = Log.ForContext<NetworkInfo>().ForContext("Component", poolConfig.Coin.Name); DetectProofOfStakeCoin(); // detect if we are running on a proof-of-stake coin. DetectSubmitBlockSupport(); // detect if the coin daemon supports submitblock call. Recache(); // recache the data initially. PrintNetworkInfo(); // print the collected network info. }
public BlockAccounter(IPoolConfig poolConfig, IObjectFactory objectFactory, IStorageLayer storageLayer, IAccountManager accountManager) { _objectFactory = objectFactory; _storageLayer = storageLayer; _accountManager = accountManager; _logger = Log.ForContext<BlockAccounter>().ForContext("Component", poolConfig.Coin.Name); if (!poolConfig.Payments.Enabled) // make sure payments are enabled. return; Active = true; }
public Redis(PoolConfig poolConfig) { _logger = Log.ForContext<Redis>().ForContext("Component", poolConfig.Coin.Name); _poolConfig = poolConfig; // the pool config. _redisConfig = (IRedisConfig) poolConfig.Storage; IsEnabled = _redisConfig.Enabled; if (IsEnabled) Initialize(); }
/// <summary> /// Creates a new instance of generation transaction. /// </summary> /// <param name="extraNonce">The extra nonce.</param> /// <param name="daemonClient">The daemon client.</param> /// <param name="blockTemplate">The block template.</param> /// <param name="poolConfig">The associated pool's configuration</param> /// <remarks> /// Reference implementations: /// https://github.com/zone117x/node-stratum-pool/blob/b24151729d77e0439e092fe3a1cdbba71ca5d12e/lib/transactions.js /// https://github.com/Crypto-Expert/stratum-mining/blob/master/lib/coinbasetx.py /// </remarks> public GenerationTransaction(IExtraNonce extraNonce, IDaemonClient daemonClient, IBlockTemplate blockTemplate, IPoolConfig poolConfig) { // TODO: we need a whole refactoring here. // we should use DI and it shouldn't really require daemonClient connection to function. BlockTemplate = blockTemplate; ExtraNonce = extraNonce; PoolConfig = poolConfig; Version = blockTemplate.Version; TxMessage = Serializers.SerializeString(poolConfig.Meta.TxMessage); LockTime = 0; // transaction inputs Inputs = new List<TxIn> { new TxIn { PreviousOutput = new OutPoint { Hash = Hash.ZeroHash, Index = (UInt32) Math.Pow(2, 32) - 1 }, Sequence = 0x0, SignatureScript = new SignatureScript( blockTemplate.Height, blockTemplate.CoinBaseAux.Flags, TimeHelpers.NowInUnixTimestamp(), (byte) extraNonce.ExtraNoncePlaceholder.Length, "/CoiniumServ/") } }; // transaction outputs Outputs = new Outputs(daemonClient, poolConfig.Coin); double blockReward = BlockTemplate.Coinbasevalue; // the amount rewarded by the block. // generate output transactions for recipients (set in config). foreach (var pair in poolConfig.Rewards) { var amount = blockReward * pair.Value / 100; // calculate the amount he recieves based on the percent of his shares. blockReward -= amount; Outputs.AddRecipient(pair.Key, amount); } // send the remaining coins to pool's central wallet. Outputs.AddPoolWallet(poolConfig.Wallet.Adress, blockReward); }
/// <summary> /// Initialize mock objects. /// </summary> public PoolTests() { // factory mockup. _objectFactory = Substitute.For<IObjectFactory>(); // pool-config mockup. _config = Substitute.For<IPoolConfig>(); _config.Daemon.Valid.Returns(true); // daemon client mockup. _daemonClient = _objectFactory.GetDaemonClient(_config.Coin.Name, _config.Daemon); _daemonClient.GetInfo().Returns(new Info()); _daemonClient.GetMiningInfo().Returns(new MiningInfo()); }
private Timer _reBroadcastTimer; // timer for rebroadcasting jobs after an pre-configured idle perioud. #endregion Fields #region Constructors public JobManager(IPoolConfig poolConfig, IDaemonClient daemonClient, IJobTracker jobTracker, IShareManager shareManager, IMinerManager minerManager, IHashAlgorithm hashAlgorithm) { _daemonClient = daemonClient; _jobTracker = jobTracker; _shareManager = shareManager; _minerManager = minerManager; _hashAlgorithm = hashAlgorithm; _poolConfig = poolConfig; _jobCounter = new JobCounter(); // todo make this ioc based too. _logger = Log.ForContext<JobManager>().ForContext("Component", poolConfig.Coin.Name); }
public BanManager(IPoolConfig poolConfig, IShareManager shareManager) { Config = poolConfig.Banning; if (!Config.Enabled) return; _logger = Log.ForContext<BanManager>().ForContext("Component", poolConfig.Coin.Name); _bannedIps = new Dictionary<IPAddress, int>(); _timer = new Timer(CheckBans, null, Timeout.Infinite, Timeout.Infinite); // create the timer as disabled. shareManager.ShareSubmitted += OnShare; CheckBans(null); }
public VardiffManager(IPoolConfig poolConfig, IShareManager shareManager) { _logger = Log.ForContext<VardiffManager>().ForContext("Component", poolConfig.Coin.Name); Config = poolConfig.Stratum.Vardiff; if (!Config.Enabled) return; shareManager.ShareSubmitted += OnShare; var variance = Config.TargetTime * ((float)Config.VariancePercent / 100); _bufferSize = Config.RetargetTime / Config.TargetTime * 4; _tMin = Config.TargetTime - variance; _tMax = Config.TargetTime + variance; }
public PaymentManager(IPoolConfig poolConfig, IBlockProcessor blockProcessor, IBlockAccounter blockAccounter, IPaymentProcessor paymentProcessor) { _poolConfig = poolConfig; _labors = new List<IPaymentLabor> { blockProcessor, blockAccounter, paymentProcessor }; _logger = Log.ForContext<PaymentManager>().ForContext("Component", poolConfig.Coin.Name); if (!_poolConfig.Payments.Enabled) // make sure payments are enabled. return; // setup the timer to run payment laberos _timer = new Timer(Run, null, _poolConfig.Payments.Interval * 1000, Timeout.Infinite); }
public PaymentProcessor(IPoolConfig poolConfig, IStorageLayer storageLayer, IDaemonClient daemonClient, IAccountManager accountManager) { _poolConfig = poolConfig; _storageLayer = storageLayer; _daemonClient = daemonClient; _accountManager = accountManager; _logger = Log.ForContext<PaymentProcessor>().ForContext("Component", poolConfig.Coin.Name); if (!_poolConfig.Payments.Enabled) // make sure payments are enabled. return; if (!ValidatePoolAddress()) // try to validate the pool wallet. return; // if we can't, stop the payment processor. if (!GetPoolAccount()) // get the pool's account name if any. return; // if we can't, stop the payment processor. Active = true; }
/// <summary> /// Initializes a new instance of the <see cref="Pool" /> class. /// </summary> /// <param name="poolConfig"></param> /// <param name="objectFactory"></param> public Pool( IPoolConfig poolConfig, IObjectFactory objectFactory) { Enforce.ArgumentNotNull(() => poolConfig); // make sure we have a config instance supplied. Enforce.ArgumentNotNull(() => objectFactory); // make sure we have a objectFactory instance supplied. _objectFactory = objectFactory; // TODO: validate pool central wallet & rewards within the startup. Config = poolConfig; _logger = Log.ForContext<Pool>().ForContext("Component", Config.Coin.Name); GenerateInstanceId(); InitDaemon(); InitManagers(); InitServers(); PrintPoolInfo(); }
public HybridStorage(IEnumerable<IStorageProvider> providers, IDaemonClient daemonClient, IPoolConfig poolConfig) { _daemonClient = daemonClient; _logger = Log.ForContext<HybridStorage>().ForContext("Component", poolConfig.Coin.Name); _coin = poolConfig.Coin.Name.ToLower(); // pool's associated coin name. // try loading providers. try { foreach (var provider in providers) { if (provider is IRedisProvider) _redisProvider = (IRedisProvider)provider; else if (provider is IMySqlProvider) _mySqlProvider = (IMySqlProvider)provider; } IsEnabled = (_redisProvider != null && _mySqlProvider != null); } catch (Exception e) { _logger.Error("Error initializing hybrid storage; {0:l}", e.Message); } }
public IStorageProvider GetStorageProvider(string type, IPoolConfig poolConfig, IStorageProviderConfig config) { var @params = new NamedParameterOverloads { {"poolConfig", poolConfig}, {"config", config} }; return _applicationContext.Container.Resolve<IStorageProvider>(type, @params); }
public IStorageLayer GetStorageLayer(string type, IEnumerable<IStorageProvider> providers, IDaemonClient daemonClient, IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { {"providers", providers}, {"daemonClient", daemonClient}, {"poolConfig", poolConfig} }; return type != StorageLayers.Empty ? _applicationContext.Container.Resolve<IStorageLayer>(type, @params) : _applicationContext.Container.Resolve<IStorageLayer>(type); }
public IVardiffManager GetVardiffManager(IPoolConfig poolConfig, IShareManager shareManager) { var @params = new NamedParameterOverloads { {"poolConfig", poolConfig}, {"shareManager", shareManager}, }; return _applicationContext.Container.Resolve<IVardiffManager>(@params); }
public IAccountManager GetAccountManager(IStorageLayer storageLayer, IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { {"storageLayer", storageLayer}, {"poolConfig", poolConfig}, }; return _applicationContext.Container.Resolve<IAccountManager>(@params); }
public JobTests() { // daemon client _daemonClient = Substitute.For<IDaemonClient>(); _daemonClient.ValidateAddress(Arg.Any<string>()).Returns(new ValidateAddress { IsValid = true }); // block template const string json = "{\"result\":{\"version\":2,\"previousblockhash\":\"22a9174d9db64f1919febc9577167764c301b755768b675291f7d34454561e9e\",\"transactions\":[],\"coinbaseaux\":{\"flags\":\"062f503253482f\"},\"coinbasevalue\":5000000000,\"target\":\"0000002bd7c30000000000000000000000000000000000000000000000000000\",\"mintime\":1402922277,\"mutable\":[\"time\",\"transactions\",\"prevblock\"],\"noncerange\":\"00000000ffffffff\",\"sigoplimit\":20000,\"sizelimit\":1000000,\"curtime\":1402922598,\"bits\":\"1d2bd7c3\",\"height\":305349},\"error\":null,\"id\":1}"; var @object = JsonConvert.DeserializeObject<DaemonResponse<BlockTemplate>>(json); _blockTemplate = @object.Result; // extra nonce _extraNonce = new ExtraNonce(0); // signature script _signatureScript = new SignatureScript( _blockTemplate.Height, _blockTemplate.CoinBaseAux.Flags, 1402922597281, (byte) _extraNonce.ExtraNoncePlaceholder.Length, "/nodeStratum/"); // pool config _poolConfig = Substitute.For<IPoolConfig>(); // create coin config. var coinConfig = Substitute.For<ICoinConfig>(); coinConfig.Options.TxMessageSupported.Returns(false); coinConfig.Options.IsProofOfStakeHybrid.Returns(false); _poolConfig.Coin.Returns(coinConfig); // outputs _outputs = Substitute.For<Outputs>(_daemonClient, coinConfig); double blockReward = 5000000000; // the amount rewarded by the block. // create rewards config. var rewardsConfig = Substitute.For<IRewardsConfig>(); _poolConfig.Rewards.Returns(rewardsConfig); // create sample reward var amount = blockReward * 0.01; blockReward -= amount; var rewards = new Dictionary<string, float> { {"mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float) amount} }; rewardsConfig.GetEnumerator().Returns(rewards.GetEnumerator()); foreach (var pair in rewards) { _outputs.AddRecipient(pair.Key, pair.Value); } // create wallet config. var walletConfig = Substitute.For<IWalletConfig>(); _poolConfig.Wallet.Returns(walletConfig); // create sample pool central wallet output. walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq"); _outputs.AddPoolWallet(walletConfig.Adress, blockReward); // job counter _jobCounter = Substitute.For<JobCounter>(); // generation transaction. _generationTransaction = new GenerationTransaction(_extraNonce, _daemonClient, _blockTemplate, _poolConfig); _generationTransaction.Inputs.First().SignatureScript = _signatureScript; _generationTransaction.Outputs = _outputs; _generationTransaction.Create(); // hash algorithm _hashAlgorithm = new Scrypt(); }
/// <summary> /// Initializes a new instance of the <see cref="Pool" /> class. /// </summary> /// <param name="poolConfig"></param> /// <param name="configManager"></param> /// <param name="objectFactory"></param> public Pool(IPoolConfig poolConfig, IConfigManager configManager, IObjectFactory objectFactory) { Enforce.ArgumentNotNull(() => poolConfig); // make sure we have a pool-config instance supplied. Enforce.ArgumentNotNull(() => configManager); // make sure we have a config-manager instance supplied. Enforce.ArgumentNotNull(() => objectFactory); // make sure we have a objectFactory instance supplied. // TODO: validate pool central wallet & rewards within the startup. _configManager = configManager; _objectFactory = objectFactory; Config = poolConfig; _logger = Log.ForContext<Pool>().ForContext("Component", Config.Coin.Name); GenerateInstanceId(); // generate unique instance id for the pool. try { InitDaemon(); // init coin daemon. InitStorage(); // init storage support. InitManagers(); // init managers. InitServers(); // init servers. Enabled = true; } catch (Exception e) { _logger.Error("Error initializing pool; {0:l}", e); Enabled = false; } }
/// <summary> /// Initializes the specified bind ip. /// </summary> /// <param name="config">The configuration.</param> /// <exception cref="System.ArgumentNullException">config;config.Daemon can not be null!</exception> public void Initialize(IPoolConfig config) { Config = config; // init coin daemon. InitDaemon(); // init managers. InitManagers(); // init servers InitServers(); }