Bitcoin Forum
May 30, 2024, 06:44:01 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Exactly how does a miner... mine?  (Read 625 times)
oko_suno (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
April 10, 2012, 04:10:31 AM
 #1

I know how to use a miner, how to use a pool and stuff like that, and I have done it before (and am right now), but I've always wondered what the actual process was to calculating hashes? What is my miner doing right now?

I've seen this:
Quote from: Pieter Wuille
Code:
doHash(block_header) {
  hasher = new SHA256();
  hasher.update(block_header[0..63]);      // update A1
  hasher.update(block_header[64..127]);  // update A2
  hash1 = hasher.getHash();
  hasher.reset();
  hasher.update(hash1);                         // update B
  hash2 = hasher.getHash();
  return hash2
}

but I have pretty much no clue what it means.
Foxpup
Legendary
*
Offline Offline

Activity: 4382
Merit: 3061


Vile Vixen and Miss Bitcointalk 2021-2023


View Profile
April 10, 2012, 04:36:30 AM
 #2

I know how to use a miner, how to use a pool and stuff like that, and I have done it before (and am right now), but I've always wondered what the actual process was to calculating hashes? What is my miner doing right now?
The idea of mining is to calculate a cryptographic hash of a block (a block is basically just a list of recent transactions, a hash of the previous block (so you can't prepare fraudulent blocks in advance), and some other stuff) such that the value of the hash is lower than a predetermined target. If it is, you win: your block gets included in the block chain and you receive the block reward (currently 50 BTC) as well all the transaction fees associated with that block. If the hash doesn't come under the target, you lose, and you have to try again by changing a small piece of data in the block (called the nonce) which causes the whole hash to change in a random way. The key point about a cryptographic hash is that it's impossible to predict what effect changing the nonce (or any other part of the data) will have on the hash: the only way to get a hash that meets the target is to try every possible nonce (a typical mining system is capable of trying millions per second) until you find one that works. This is key to the security of Bitcoin: it's impossible for anyone to introduce a fraudulent block without first using a ton of computing power to find one that meets the hash target. Not only that, they'd need (on average) more computing power than the rest of the network combined, because if anyone else finds a real block first, all the effort trying to produce a fraudulent block is wasted.

I've seen this:
Quote from: Pieter Wuille
Code:
doHash(block_header) {
  hasher = new SHA256();
  hasher.update(block_header[0..63]);      // update A1
  hasher.update(block_header[64..127]);  // update A2
  hash1 = hasher.getHash();
  hasher.reset();
  hasher.update(hash1);                         // update B
  hash2 = hasher.getHash();
  return hash2
}

but I have pretty much no clue what it means.
This code just calls the hashing function on the blocks, there's nothing special about it.

Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
oko_suno (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
April 10, 2012, 05:00:52 AM
 #3

And the target is changed every 2016 blocks so that the difficulty of mining can be changed... ok I get it now, thank you!
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!