unsafe void Work(Work work)
{
// allocate buffers to hold hashing work
byte[] round1Blocks, round2Blocks;
uint[] round1State, round2State;
// allocate buffers
PrepareWork(work, out round1Blocks, out round1State, out round2Blocks, out round2State);
// search for nonce value
uint? nonce;
fixed (byte* round1BlocksPtr = round1Blocks, round2BlocksPtr = round2Blocks)
fixed (uint* round1StatePtr = round1State, round2StatePtr = round2State)
nonce = Search(work, round1StatePtr, round1BlocksPtr + Sha256.SHA256_BLOCK_SIZE, round2StatePtr, round2BlocksPtr);
// solution found!
if (nonce != null)
{
// replace header data on work
fixed (byte* headerPtr = work.Header)
((uint*)headerPtr)[19] = Memory.ReverseEndian((uint)nonce);
// let the caller know
Context.SubmitWork(this, work, GetType().Name);
}
}