Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: TeraPool on July 12, 2011, 07:43:58 PM



Title: Query bitcoind for block number when you only know the block hash?
Post by: TeraPool on July 12, 2011, 07:43:58 PM
So when running a pool, you can determine what your block_hash is from your "solution" that pushpool provides. (http://forum.bitcoin.org/index.php?topic=11043.0)

How then would you use that block_hash?

I don't really want to rely on scraping and parsing blockexplorer.com to get the relevant information I need. (ie by concatenating the block hash onto http://blockexplorer.com/block/BLOCK_HASH_HERE )

When you are given the solution from pushpool. You have the timestamp, nonce, merkle root, and previous block hash to work with as well as the current block hash.

Any way to get a transaction id or specific block number or anything else from that? Or how would you determine whether the solution found was a valid one (and not stale/invalid to the network?)


Title: Re: Query bitcoind for block number when you only know the block hash?
Post by: JoelKatz on July 12, 2011, 08:29:02 PM
So when running a pool, you can determine what your block_hash is from your "solution" that pushpool provides. (http://forum.bitcoin.org/index.php?topic=11043.0)

How then would you use that block_hash?
You return it to whatever gave it to you.

Quote
I don't really want to rely on scraping and parsing blockexplorer.com to get the relevant information I need. (ie by concatenating the block hash onto http://blockexplorer.com/block/BLOCK_HASH_HERE )
That would only work if the block made it into the public hash chain. Are you talking about solved blocks that have already been committed and confirmed?

Quote
When you are given the solution from pushpool. You have the timestamp, nonce, merkle root, and previous block hash to work with as well as the current block hash.

Any way to get a transaction id or specific block number or anything else from that? Or how would you determine whether the solution found was a valid one (and not stale/invalid to the network?)
That's not the miner's problem. The miner is given enough information to solve the block or generate a work unit. The miner does not have the entire block, just the header. In general, there's no way to get the rest of the information.

What's your outer problem? Why do you think you need this information and where are you when you're trying to get it? (Are you the miner? Are you the pool manger?)


Title: Re: Query bitcoind for block number when you only know the block hash?
Post by: TeraPool on July 12, 2011, 10:05:04 PM
Thanks JoelKatz.

In this particular problem, I am the pool manager.

When pushpool (default setup) solves a block, it makes a note in the mysql database by placing a "Y" in both the "our_result" and "upstream_result" columns.

I can then query the database every few minutes to look for such an event, extract it's "solution" from that same table and calculate that block's hash value out of it.

What I really need to do is be able to query the ./bitcoind listtransactions command with the exact time that I can extract from the assumed valid and paid out "solution". If I can correspond the two times (from listtransactions and pushpool's block solution) then I can assume that the block is valid and after x number of confirmations... pay it out to my miners appropriately.

In writing the above paragraph I believe I just realized what must be done.

1) Dump all transaction information using the php json rpc and listtransactions command every day to a mysql table. Giving me a list of all blocks that were in the "generate" category that day.

2) Match the times in the above generated table to the times in the assumed valid pushpool solution.

3) Calculate number of shares per worker created during each gap between solved blocks and pay them out accordingly.

Wow, you're like a technical psychologist or something. Thanks again.