ctstone / csredis

.NET client for Redis and Redis Sentinel (2.8). Includes both synchronous and asynchronous clients.
Other
292 stars 111 forks source link

redispipeline flush() not supported exception #18

Closed bonesoul closed 10 years ago

bonesoul commented 10 years ago

Using pipelines and similar to exception in; #17

System.NotSupportedException was unhandled by user code
  HResult=-2146233067
  Message=Cannot write to a BufferedStream while the read buffer is not empty if the underlying stream is not seekable. Ensure that the stream underlying this BufferedStream can seek or avoid interleaving read and write operations on this BufferedStream.
  Source=mscorlib
  StackTrace:
       at System.IO.BufferedStream.ClearReadBufferBeforeWrite()
       at System.IO.BufferedStream.Write(Byte[] array, Int32 offset, Int32 count)
       at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize)
       at CSRedis.Internal.RedisPipeline.Flush() in f:\Source\CoiniumServ\deps\csredis\CSRedis\Internal\RedisPipeline.cs:line 38
       at CSRedis.Internal.RedisConnection.EndPipe() in f:\Source\CoiniumServ\deps\csredis\CSRedis\Internal\RedisConnection.cs:line 155
       at CSRedis.RedisClient.EndPipe() in f:\Source\CoiniumServ\deps\csredis\CSRedis\RedisClient.cs:line 175
       at CoiniumServ.Persistance.Redis.RedisCS.AddShare(IShare share) in f:\Source\CoiniumServ\src\CoiniumServ\Persistance\Redis\RedisCS.cs:line 95
       at CoiniumServ.Shares.ShareManager.HandleValidShare(IShare share) in f:\Source\CoiniumServ\src\CoiniumServ\Shares\ShareManager.cs:line 105
       at CoiniumServ.Shares.ShareManager.ProcessShare(IStratumMiner miner, String jobId, String extraNonce2, String nTimeString, String nonceString) in f:\Source\CoiniumServ\src\CoiniumServ\Shares\ShareManager.cs:line 86
       at CoiniumServ.Server.Mining.Stratum.Service.StratumService.SubmitWork(String user, String jobId, String extraNonce2, String nTime, String nonce) in f:\Source\CoiniumServ\src\CoiniumServ\Server\Mining\Stratum\Service\StratumService.cs:line 95
  InnerException: 

caused by;

                if (!IsEnabled || !IsConnected)
                    return;

                var coin = _poolConfig.Coin.Name.ToLower(); // the coin we are working on.

                _client.StartPipe(); // batch the commands.

                // add the share to round 
                var currentKey = string.Format("{0}:shares:round:current", coin);
                _client.HIncrByFloat(currentKey, share.Miner.Username, share.Difficulty);

                // increment shares stats.
                var statsKey = string.Format("{0}:stats", coin);
                _client.HIncrBy(statsKey, share.IsValid ? "validShares" : "invalidShares", 1);

                // add to hashrate
                if (share.IsValid)
                {
                    var hashrateKey = string.Format("{0}:hashrate", coin);
                    var entry = string.Format("{0}:{1}", share.Difficulty, share.Miner.Username);
                    _client.ZAdd(hashrateKey, Tuple.Create(TimeHelpers.NowInUnixTime(), entry));
                }

                _client.EndPipe(); // execute the batch commands.
ctstone commented 10 years ago

Duplicate of #17