How does the RPC getwork system work?
From the wiki:
[data] If [data] is not specified, returns formatted hash data to work on:
* "midstate" : precomputed hash state after hashing the first half of the data
* "data" : block data
* "hash1" : formatted hash buffer for second hash
* "target" : little endian hash target
If [data] is specified, tries to solve the block and returns true if it was successful.
You have solved the block if it is
sha-256(sha-256(data)) < difficulty target
Is block data just the header?
Also, is midstate the sha-256 of the first 76 bytes (to where the nonce starts)?
Presumably, this would allow the miners to save state of their SHA calculation and reset to byte 76 instead of doing the calculations over and over.
When a miner hits the target, how does it send the nonce back?