/// <summary> /// Creates a new miner instance. /// </summary> /// <param name="id"></param> /// <param name="extraNonce"></param> /// <param name="connection"></param> /// <param name="pool"></param> /// <param name="minerManager"></param> /// <param name="storageLayer"></param> public StratumMiner(int id, UInt32 extraNonce, IConnection connection, IPool pool, IMinerManager minerManager, IStorageLayer storageLayer) { Id = id; // the id of the miner. ExtraNonce = extraNonce; Connection = connection; // the underlying connection. Pool = pool; _minerManager = minerManager; _storageLayer = storageLayer; Subscribed = false; // miner has to subscribe. Authenticated = false; // miner has to authenticate. _logger = Log.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name); _packetLogger = LogManager.PacketLogger.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name); _rpcResultHandler = callback => { var asyncData = ((JsonRpcStateAsync)callback); // get the async data. var result = asyncData.Result + "\n"; // read the result. var response = Encoding.UTF8.GetBytes(result); // set the response. Connection.Send(response); // send the response. _packetLogger.Verbose("tx: {0}", result.PrettifyJson()); }; }
/// <summary> /// Creates a new miner instance. /// </summary> /// <param name="id"></param> /// <param name="extraNonce"></param> /// <param name="connection"></param> /// <param name="pool"></param> /// <param name="minerManager"></param> /// <param name="storageLayer"></param> public StratumMiner(int id, UInt32 extraNonce, IConnection connection, IPool pool, IMinerManager minerManager, IStorageLayer storageLayer) { Id = id; // the id of the miner. ExtraNonce = extraNonce; Connection = connection; // the underlying connection. Pool = pool; _minerManager = minerManager; _storageLayer = storageLayer; Subscribed = false; // miner has to subscribe. Authenticated = false; // miner has to authenticate. _logger = Log.ForContext <StratumMiner>().ForContext("Component", pool.Config.Coin.Name); _packetLogger = LogManager.PacketLogger.ForContext <StratumMiner>().ForContext("Component", pool.Config.Coin.Name); _rpcResultHandler = callback => { var asyncData = ((JsonRpcStateAsync)callback); // get the async data. var result = asyncData.Result + "\n"; // read the result. var response = Encoding.UTF8.GetBytes(result); // set the response. Connection.Send(response); // send the response. _packetLogger.Verbose("tx: {0}", result.PrettifyJson()); }; }
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; }
private bool InitStorage() { // load the providers for the current storage layer. var providers = Config.Storage.Layer.Providers.Select( providerConfig => _objectFactory.GetStorageProvider( providerConfig is IMySqlProviderConfig ? StorageProviders.MySql : StorageProviders.Redis, Config, providerConfig)).ToList(); // start the migration manager if needed if (Config.Storage.Layer is HybridStorageConfig) { _objectFactory.GetMigrationManager((IMySqlProvider)providers.First(p => p is MySqlProvider), Config); // run migration manager. } // load the storage layer. if (Config.Storage.Layer is HybridStorageConfig) { _storage = _objectFactory.GetStorageLayer(StorageLayers.Hybrid, providers, Daemon, Config); } else if (Config.Storage.Layer is MposStorageConfig) { _storage = _objectFactory.GetStorageLayer(StorageLayers.Mpos, providers, Daemon, Config); } else if (Config.Storage.Layer is NullStorageConfig) { _storage = _objectFactory.GetStorageLayer(StorageLayers.Empty, providers, Daemon, Config); } return(true); }
public BlockProcessorTests() { // create mockup objects required for tests. _daemonClient = Substitute.For<IDaemonClient>(); _poolConfig = Substitute.For<IPoolConfig>(); _storageLayer = Substitute.For<IStorageLayer>(); }
public BlockProcessorTests() { // create mockup objects required for tests. _daemonClient = Substitute.For <IDaemonClient>(); _poolConfig = Substitute.For <IPoolConfig>(); _storageLayer = Substitute.For <IStorageLayer>(); }
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 IBlocksCache GetBlocksCache(IStorageLayer storageLayer) { var @params = new NamedParameterOverloads { { "storageLayer", storageLayer }, }; return(_applicationContext.Container.Resolve <IBlocksCache>(@params)); }
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); }
public IPaymentRepository GetPaymentRepository(IStorageLayer storageLayer) { var @params = new NamedParameterOverloads { { "storageLayer", storageLayer } }; return(_applicationContext.Container.Resolve <IPaymentRepository>(@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 IAccountManager GetAccountManager(IStorageLayer storageLayer, IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { { "storageLayer", storageLayer }, { "poolConfig", poolConfig }, }; return(_applicationContext.Container.Resolve <IAccountManager>(@params)); }
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; }
/// <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 PaymentRound(IPersistedBlock block, IStorageLayer storageLayer, IAccountManager accountManager) { Block = block; _storageLayer = storageLayer; _accountManager = accountManager; Payments = new List<IPayment>(); _shares = _storageLayer.GetShares(Block); // load the shares for the round. CalculatePayments(); // calculate the per-user payments. }
/// <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 PaymentRound(IPersistedBlock block, IStorageLayer storageLayer, IAccountManager accountManager) { Block = block; _storageLayer = storageLayer; _accountManager = accountManager; Payments = new List <IPayment>(); _shares = _storageLayer.GetShares(Block); // load the shares for the round. CalculatePayments(); // calculate the per-user payments. }
public IPaymentRound GetPaymentRound(IPersistedBlock block, IStorageLayer storageLayer, IAccountManager accountManager) { var @params = new NamedParameterOverloads { { "block", block }, { "storageLayer", storageLayer }, { "accountManager", accountManager } }; return(_applicationContext.Container.Resolve <IPaymentRound>(@params)); }
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 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 IMinerManager GetMinerManager(IPoolConfig poolConfig, IStorageLayer storageLayer, IAccountManager accountManager, IDaemonClient daemonClient) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig }, { "storageLayer", storageLayer }, { "accountManager", accountManager }, { "daemonClient", daemonClient }, }; return(_applicationContext.Container.Resolve <IMinerManager>(@params)); }
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 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; }
public PaymentRepository(IStorageLayer storageLayer) { _storageLayer = storageLayer; }
public IPaymentRound GetPaymentRound(IPersistedBlock block, IStorageLayer storageLayer, IAccountManager accountManager) { var @params = new NamedParameterOverloads { {"block", block}, {"storageLayer", storageLayer}, {"accountManager", accountManager} }; return _applicationContext.Container.Resolve<IPaymentRound>(@params); }
public AccountManager(IStorageLayer storageLayer, IPoolConfig poolConfig) { _storageLayer = storageLayer; _logger = Log.ForContext<HybridStorage>().ForContext("Component", poolConfig.Coin.Name); }
public AccountManager(IStorageLayer storageLayer, IPoolConfig poolConfig) { _storageLayer = storageLayer; _logger = Log.ForContext <HybridStorage>().ForContext("Component", poolConfig.Coin.Name); }
public BlocksCache(IStorageLayer storageLayer) { _storageLayer = storageLayer; _storage = new List <IPersistedBlock>(); }
public BlocksRepository(IStorageLayer storageLayer) { _storageLayer = storageLayer; _latestBlocks = new List <IPersistedBlock>(); _lastPaid = new List <IPersistedBlock>(); }
public IPaymentRepository GetPaymentRepository(IStorageLayer storageLayer) { var @params = new NamedParameterOverloads { {"storageLayer", storageLayer} }; return _applicationContext.Container.Resolve<IPaymentRepository>(@params); }
public IPaymentProcessor GetPaymentProcessor(IPoolConfig poolConfig, IStorageLayer storageLayer, IDaemonClient daemonClient, IAccountManager accountManager) { var @params = new NamedParameterOverloads { {"poolConfig", poolConfig}, {"storageLayer", storageLayer}, {"daemonClient", daemonClient}, {"accountManager", accountManager}, }; return _applicationContext.Container.Resolve<IPaymentProcessor>(@params); }
public IAccountManager GetAccountManager(IStorageLayer storageLayer, IPoolConfig poolConfig) { var @params = new NamedParameterOverloads { {"storageLayer", storageLayer}, {"poolConfig", poolConfig}, }; return _applicationContext.Container.Resolve<IAccountManager>(@params); }
public IBlockProcessor GetBlockProcessor(IPoolConfig poolConfig, IDaemonClient daemonClient, IStorageLayer storageLayer) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig }, { "daemonClient", daemonClient }, { "storageLayer", storageLayer }, }; return(_applicationContext.Container.Resolve <IBlockProcessor>(@params)); }
public IShareManager GetShareManager(IPoolConfig poolConfig, IDaemonClient daemonClient, IJobTracker jobTracker, IStorageLayer storageLayer) { var @params = new NamedParameterOverloads { { "poolConfig", poolConfig }, { "daemonClient", daemonClient }, { "jobTracker", jobTracker }, { "storageLayer", storageLayer } }; return(_applicationContext.Container.Resolve <IShareManager>(@params)); }
private void InitStorage() { // load the providers for the current storage layer. var providers = Config.Storage.Layer.Providers.Select( providerConfig => _objectFactory.GetStorageProvider( providerConfig is IMySqlProviderConfig ? StorageProviders.MySql : StorageProviders.Redis, Config, providerConfig)).ToList(); // start the migration manager if needed if (Config.Storage.Layer is HybridStorageConfig) _objectFactory.GetMigrationManager((IMySqlProvider)providers.First(p => p is MySqlProvider), Config); // run migration manager. // load the storage layer. if (Config.Storage.Layer is HybridStorageConfig) _storage = _objectFactory.GetStorageLayer(StorageLayers.Hybrid, providers, Daemon, Config); else if (Config.Storage.Layer is MposStorageConfig) _storage = _objectFactory.GetStorageLayer(StorageLayers.Mpos, providers, Daemon, Config); else if (Config.Storage.Layer is NullStorageConfig) _storage = _objectFactory.GetStorageLayer(StorageLayers.Empty, providers, Daemon, Config); }
public IShareManager GetShareManager(IPoolConfig poolConfig, IDaemonClient daemonClient, IJobTracker jobTracker, IStorageLayer storageLayer) { var @params = new NamedParameterOverloads { {"poolConfig", poolConfig}, {"daemonClient", daemonClient}, {"jobTracker", jobTracker}, {"storageLayer", storageLayer} }; return _applicationContext.Container.Resolve<IShareManager>(@params); }
public BlocksRepository(IStorageLayer storageLayer) { _storageLayer = storageLayer; _latestBlocks = new List<IPersistedBlock>(); _lastPaid = new List<IPersistedBlock>(); }