P2Pool code documentation
Ignore this page for the minute. Is just a scratch pad for documenting the p2pool code. Will tidy up once initial pass done.
|p2pool/main.py||Main Startup and initialisation code|
|p2pool/data.py||P2Pool main data structures|
|p2pool/util/pack.py||Handling of over the wire data structures|
Makes extensive use of twisted.defer. This allows it to "yield" to allow long running network code to complete. Read up on Python Generators and this before progressing!
Contains main startup code.
Tests connection to bitcoind. Prints hash of latest block to show bitcoind is up to date.
Tests connection to p2pool network.
Gets address to use for payout either from file or bitcoind. Validates address and checks local bitcoind owns it.
Contains the main data structures used in p2pool. These are:
Serialized SHA256 engine state, used to prove that a coinbase transaction contains some data near the end without sending the entire transaction.
|extra_data||String(0)||Comments say this is a hack|
Bitcoin block header, excluding the merkle root. Included in shares, where the merkle root is computed implicitly from the coinbase transaction and the merkle branch.
|previous_block||None or Int(256)||?|
Information contained within a share that is only relevant to P2Pool and that the client has control over (i.e. its value isn't fixed by the protocol rules).
|previous_share_hash||None or int(256)||?|
|stale_info||String(32)||Enum (orpan, dao, unk253, unk252...???|
Information contained within a share that is only relevant to P2Pool
|share_data||share_data_type (see above)||?|
|far_share_hash||none or int(256)||?|
I think this handles all the binary data types used in the bitcoin protocol to send data over the network wire. These are nasty as very low level and many big endian/little endian complications. The p2pool network protocol uses these also. Do not think you need to really understand this unless making changes at this low level.
At bottom has DEBUG flag. Change to true to get more output. (running p2pool with --debug does this) Other than that just returns version number for git if it can.