void AssignWork(Client c) { if (mBlock != null) { //mEventLog.RecordEvent(EventLog.EventType.HashWork, string.Format("Allocating {0} hashes for client: {1}", c.mDesiredHashes, c.ToLogString())); HashManager.HashBlock hashes = mBlock.mHashMan.Allocate(c.mDesiredHashes, c); if (hashes != null) { //mEventLog.RecordEvent(EventLog.EventType.HashWork, string.Format("Sending hash range ({0} - {1}) to client: {2}", hashes.Start, hashes.Start + hashes.Count, c.ToLogString())); c.SendWork(hashes, mBlock); } } }
public void SendWork(HashManager.HashBlock hashBlock, WorkBlock block) { mHashBlock = hashBlock; MemoryStream stream = new MemoryStream(); BinaryWriter bw = new BinaryWriter(stream); bw.Write((byte)3); bw.Write(hashBlock.Start); bw.Write(hashBlock.Count); bw.Write((int)block.mAlgorithm); bw.Write(block.target); bw.Write(block.data); SendPacket(stream.ToArray()); bw.Close(); mCurrentBlock = block; mState = State.Busy; mWorkSent = DateTime.Now; }