Bitcoin Forum
April 24, 2024, 05:56:18 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What a miner does?  (Read 1217 times)
blap (OP)
Newbie
*
Offline Offline

Activity: 51
Merit: 0


View Profile
June 03, 2011, 04:07:57 PM
 #1

Just to understand the process, what a miner does? Hash the block header (https://en.bitcoin.it/wiki/Block_hashing_algorithm)? Someone has a pseudo-code for that? I have looked inside m0mchil-poclbm and jsMiner.js... It was confusing for me...
 Cry
Transactions must be included in a block to be properly completed. When you send a transaction, it is broadcast to miners. Miners can then optionally include it in their next blocks. Miners will be more inclined to include your transaction if it has a higher transaction fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713981378
Hero Member
*
Offline Offline

Posts: 1713981378

View Profile Personal Message (Offline)

Ignore
1713981378
Reply with quote  #2

1713981378
Report to moderator
1713981378
Hero Member
*
Offline Offline

Posts: 1713981378

View Profile Personal Message (Offline)

Ignore
1713981378
Reply with quote  #2

1713981378
Report to moderator
Pieter Wuille
Legendary
*
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
June 03, 2011, 04:43:05 PM
 #2


loop:
  var blockheader = DoGetWorkRPCCall()
  var target = ExtractTarget(blockheader)
  for nonce in 0..4294967295:
    var attempt = ModifyNonce(blockheader, nonce)
    var hash = SHA256(SHA256(attempt))
    if (hash < target)
      ReportSolution(attempt)


I do Bitcoin stuff.
compro01
Hero Member
*****
Offline Offline

Activity: 590
Merit: 500



View Profile
June 03, 2011, 05:17:15 PM
 #3


loop:
  var blockheader = DoGetWorkRPCCall()
  var target = ExtractTarget(blockheader)
  for nonce in 0..4294967295:
    var attempt = ModifyNonce(blockheader, nonce)
    var hash = SHA256(SHA256(attempt))
    if (hash < target)
      ReportSolution(attempt)



i believe should be (hash <= target)

otherwise, looks right to me.
blap (OP)
Newbie
*
Offline Offline

Activity: 51
Merit: 0


View Profile
June 03, 2011, 06:24:11 PM
 #4

What is "ModifyNonce(blockheader, nonce)"?
compro01
Hero Member
*****
Offline Offline

Activity: 590
Merit: 500



View Profile
June 03, 2011, 06:36:32 PM
 #5

What is "ModifyNonce(blockheader, nonce)"?

sticks the incremented nonce into the block header, replacing the previously tried one.
dserrano5
Legendary
*
Offline Offline

Activity: 1974
Merit: 1029



View Profile
June 03, 2011, 08:25:13 PM
 #6

What is "ModifyNonce(blockheader, nonce)"?

sticks the incremented nonce into the block header, replacing the previously tried one.

I'm a total noob at this but, if I didn't misunderstand this, the current timestamp is also took into account. Else, a given block could be unsolvable if it happens that none of the 2**32 nonces result in a hash less than the target.
compro01
Hero Member
*****
Offline Offline

Activity: 590
Merit: 500



View Profile
June 03, 2011, 10:54:58 PM
 #7

What is "ModifyNonce(blockheader, nonce)"?

sticks the incremented nonce into the block header, replacing the previously tried one.

I'm a total noob at this but, if I didn't misunderstand this, the current timestamp is also took into account. Else, a given block could be unsolvable if it happens that none of the 2**32 nonces result in a hash less than the target.

Yes, there would need to be a ModifyTimestamp(blockheaders, timestamp) step, but whenever the nonce overflows, the ExtraNonce part of the generation transaction gets incremented.
Pieter Wuille
Legendary
*
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
June 04, 2011, 12:39:03 AM
 #8

Miners typically do not modify the timestamp - they just use the timestamp in the block, as received by the getwork call.

I do Bitcoin stuff.
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!