public void MoveSharesToCurrentRound(IPaymentRound round) { try { if (!IsEnabled || !_redisProvider.IsConnected) { return; } if (round.Block.Status == BlockStatus.Confirmed || round.Block.Status == BlockStatus.Pending) { return; } var currentRound = string.Format("{0}:shares:round:current", _coin); // current round key. var roundShares = string.Format("{0}:shares:round:{1}", _coin, round.Block.Height); // rounds shares key. //_client.StartPipeTransaction(); // batch the commands as atomic. // add shares to current round again. foreach (var pair in round.Shares) { _redisProvider.Client.HIncrByFloat(currentRound, pair.Key, pair.Value); } _redisProvider.Client.Del(roundShares); // delete the associated shares. //_client.EndPipe(); // execute the batch commands. } catch (Exception e) { _logger.Error("An exception occured while moving shares: {0:l}", e.Message); } }
public void UpdateBlock(IPaymentRound round) { try { if (!IsEnabled) { return; } using (var connection = new MySqlConnection(_mySqlProvider.ConnectionString)) { connection.Execute( @"update blocks set orphaned = @orphaned, confirmed = @confirmed where height = @height", new { orphaned = round.Block.Status == BlockStatus.Orphaned, confirmed = round.Block.Status == BlockStatus.Confirmed, height = round.Block.Height }); } } catch (Exception e) { _logger.Error("An exception occured while updating block; {0:l}", e.Message); } }
public void RemoveShares(IPaymentRound round) { try { if (!IsEnabled || !_redisProvider.IsConnected) { return; } var roundKey = string.Format("{0}:shares:round:{1}", _coin, round.Block.Height); _redisProvider.Client.Del(roundKey); // delete the associated shares. } catch (Exception e) { _logger.Error("An exception occurred while deleting shares: {0:l}", e.Message); } }
public void MoveBlock(IPaymentRound round) { try { if (!IsEnabled || !IsConnected) { return; } if (round.Block.Status == BlockStatus.Pending) { return; } // re-flag the rounds. var pendingKey = string.Format("{0}:blocks:pending", _coin); // old key for the round. var newKey = string.Empty; // new key for the round. switch (round.Block.Status) { case BlockStatus.Orphaned: newKey = string.Format("{0}:blocks:orphaned", _coin); break; case BlockStatus.Confirmed: newKey = string.Format("{0}:blocks:confirmed", _coin); break; } var entry = string.Format("{0}:{1}:{2}", round.Block.BlockHash, round.Block.TransactionHash, round.Block.Amount); // entry format: blockHash:txHash:Amount //_client.StartPipeTransaction(); // batch the commands as atomic. _client.ZRemRangeByScore(pendingKey, round.Block.Height, round.Block.Height); _client.ZAdd(newKey, Tuple.Create(round.Block.Height, entry)); //_client.EndPipe(); // execute the batch commands. } catch (Exception e) { _logger.Error("An exception occured while moving block: {0:l}", e.Message); } }
public void RemoveShares(IPaymentRound round) { return; }
public void RemoveShares(IPaymentRound round) { // this function is not supported as this functionality is handled by mpos itself. throw new NotSupportedException(); }
public void MoveSharesToCurrentRound(IPaymentRound round) { if (!IsEnabled || !IsConnected) return; if (round.Block.Status == BlockStatus.Confirmed || round.Block.Status == BlockStatus.Pending) return; var coin = _poolConfig.Coin.Name.ToLower(); // the coin we are working on. var currentRound = string.Format("{0}:shares:round:current", coin); // current round key. var roundShares = string.Format("{0}:shares:round:{1}", coin, round.Block.Height); // rounds shares key. // add shares to current round again. foreach (var pair in round.Shares) { _database.HashIncrementAsync(currentRound, pair.Key, pair.Value, CommandFlags.FireAndForget); } // delete the associated shares. _database.KeyDeleteAsync(roundShares, CommandFlags.FireAndForget); // delete the associated shares. }
public void MoveBlock(IPaymentRound round) { if (!IsEnabled || !IsConnected) return; if (round.Block.Status == BlockStatus.Pending) return; var coin = _poolConfig.Coin.Name.ToLower(); // the coin we are working on. // re-flag the rounds. var pendingKey = string.Format("{0}:blocks:pending", coin); // old key for the round. var newKey = string.Empty; // new key for the round. switch (round.Block.Status) { case BlockStatus.Kicked: newKey = string.Format("{0}:blocks:kicked", coin); break; case BlockStatus.Orphaned: newKey = string.Format("{0}:blocks:orphaned", coin); break; case BlockStatus.Confirmed: newKey = string.Format("{0}:blocks:confirmed", coin); break; } var entry = string.Format("{0}:{1}", round.Block.BlockHash, round.Block.TransactionHash); _database.SortedSetRemoveRangeByScoreAsync(pendingKey, round.Block.Height, round.Block.Height, Exclude.None, CommandFlags.FireAndForget); _database.SortedSetAddAsync(newKey, entry, round.Block.Height, CommandFlags.FireAndForget); }
public void DeleteShares(IPaymentRound round) { if (!IsEnabled || !IsConnected) return; var coin = _poolConfig.Coin.Name.ToLower(); // the coin we are working on. var roundKey = string.Format("{0}:shares:round:{1}", coin, round.Block.Height); _database.KeyDeleteAsync(roundKey, CommandFlags.FireAndForget); // delete the associated shares. }
public void UpdateBlock(IPaymentRound round) { // The function is not supported as it's only required by payments processor. In MPOS mode payments processor should be disabled. throw new NotImplementedException(); }
public void UpdateBlock(IPaymentRound round) { return; // just skip. }
public void MoveSharesToCurrentRound(IPaymentRound round) { return; // just skip. }
public void RemoveShares(IPaymentRound round) { return; // just skip. }
public void RemoveShares(IPaymentRound round) { try { if (!IsEnabled || !_redisProvider.IsConnected) return; var roundKey = string.Format("{0}:shares:round:{1}", _coin, round.Block.Height); _redisProvider.Client.Del(roundKey); // delete the associated shares. } catch (Exception e) { _logger.Error("An exception occured while deleting shares: {0:l}", e.Message); } }