Bitcoin Forum
May 04, 2024, 11:23:21 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Mining: separating the steps (Coding)  (Read 833 times)
astaldo (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
May 06, 2016, 03:29:29 PM
 #1

Hi there,
I'm a software programmer and I'm interested in the specific steps inside a mining client.
I know i cannot efficiently mine with my PC but I'm interested in the steps to reproduce.

I'm using BitcoinJ to develop a small program to decode the Blocks from the standard LevelDB that the bitcoin core client downloaded.

If I understand it correctly, it's all about the 80 bytes header.
The variable things are the previous block hash and the merkle hash of the transactions contained in the new block (plus time and nonce).

So my first question:
Can a miner simply select some of the pending transactions to be included in the new block (=> the merkle hash)?

How are the solo mining clients doing this? Do they ask for a new block (as I could do in the debug console of the core client) and try to make it fit (by adjsuting the nonce ) or are they aware of all pending transactions and puzzle them together until it fits?

Thanks in advance,
Astaldo
1714821801
Hero Member
*
Offline Offline

Posts: 1714821801

View Profile Personal Message (Offline)

Ignore
1714821801
Reply with quote  #2

1714821801
Report to moderator
1714821801
Hero Member
*
Offline Offline

Posts: 1714821801

View Profile Personal Message (Offline)

Ignore
1714821801
Reply with quote  #2

1714821801
Report to moderator
Be very wary of relying on JavaScript for security on crypto sites. The site can change the JavaScript at any time unless you take unusual precautions, and browsers are not generally known for their airtight security.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714821801
Hero Member
*
Offline Offline

Posts: 1714821801

View Profile Personal Message (Offline)

Ignore
1714821801
Reply with quote  #2

1714821801
Report to moderator
1714821801
Hero Member
*
Offline Offline

Posts: 1714821801

View Profile Personal Message (Offline)

Ignore
1714821801
Reply with quote  #2

1714821801
Report to moderator
1714821801
Hero Member
*
Offline Offline

Posts: 1714821801

View Profile Personal Message (Offline)

Ignore
1714821801
Reply with quote  #2

1714821801
Report to moderator
mwizard
Full Member
***
Offline Offline

Activity: 203
Merit: 100


View Profile
May 07, 2016, 12:32:11 AM
Last edit: May 07, 2016, 01:10:54 AM by mwizard
 #2

It is entirely up to the pool operator or solo miner to select which transactions to include.  A pool, or solo miner, is aware of all transactions in their mempool.  They build a block from these transactions and then start looking for valid hashes.  

So what goes in a block depends first of all on what the solo node or pool has accepted into its mempool and then on which transactions they selected from their mempool.  If you want the details see https://bitcoin.org/en/developer-guide#mining.

The only restriction on blocks is that pools or solo miners must only build a block that will be accepted and relayed around the network.  For block rules see https://en.bitcoin.it/wiki/Protocol_rules

For what mempool will include see such parameters as mempoolexpiry, mintxfee and minrelaytxfee.

Remote 'Miners' using a central pool only calculate sha-hashes as directed by the pool operator. They do not know block contents.  A hardware miner such as an S7 is simply calculating sha-hashes values for the pool operator or solo miner.






astaldo (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
May 07, 2016, 01:50:15 PM
 #3

Thanks for the info.
Do you know the internal techniques of a solo (asic) miner?
I realized they run with programs like cgminer and Im thinking about how they do the work.
How do they put the pieces together when they do solo mining?
Who is collecting the transactions to build the next new block?
Is there any chance I could realize that Im not working on the same block than someone else?
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!