7 ms·
The bitcoin mining algorithm from a programmer's viewpoint
- acchow 13y agoHow does the network raise the difficulty? How do the nodes agree on a "next difficulty". It's somewhat surprising to me that the next difficulty level isn't an input the hash function. H(B, random number, next difficulty level). Edit: How does the network agree on clock? How does it handle rogues?
- jadeddrag 13y agoSince the difficulty is the proportion to the amount of time over or under two weeks the previous 2016 blocks took to find, it's a deterministic calculation that other nodes use to accept and validate each new block. And since it's in the best interest of nodes to keep the longest chain of blocks, it's not in their interest to break this rule. (or they will end up on an abandoned blockchain fork)
- oleganza 13y agoEach block has a timestamp. Each 2016 blocks difficulty is adjusted so that next 2016 blocks are produced closer to 10 minute interval between the blocks. Nodes do not tolerate timestamps 2 hours in the future relative to their own timestamps: https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L2039 https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#... Since difficulty is adjusted based on a simple median, if the hashrate is always growing (like for the past 8 months), average time between blocks is always below the target 10 minutes (it was around 7-8 minutes on average).
- jiggy2011 13y agoBy looking at how long it took to mine the last set of blocks. The rate is supposed to be 1 block per 10 minutes so you can estimate the hashing power of the network by looking at the time taken to solve the last X blocks. If it's too fast, difficulty goes up, too slow and it goes down. The nodes can "agree" without needing to communicate , because they all use the same formula (and share the blockchain) they should all agree on the same answer for what the difficulty of the next set of blocks should be.
- maaku 13y agoThe difficulty is in the block header, B.
- Moral_ 13y agoHow is the hash compared to a difficulty? The current difficulty is 609482680... How do you compare a hash to a number to determine if it's greater than the number?
- jadeddrag 13y ago"What is the formula for difficulty? difficulty = maximum_target / current_target (target is a 256 bit number)" source: https://en.bitcoin.it/wiki/Difficulty https://en.bitcoin.it/wiki/Difficulty
- blibble 13y agothe proof of work requires miners to generate some value such that HASH(block_value, generated_value) begins with fn(difficulty) zeros. miners choose a value for generated_value, hash it and hope it comes out with the required number of zeros, if not they try again, and again, and again until they (or someone else) finds a value. for simplicity let's say the fn(x) = x. difficulty of 5? hash must have 5 zeros at the beginning: 00000XXXXXXXXXXXXXXXXXXXXXXXXX 10? must have 10: 0000000000XXXXXXXXXXXXXXXXXXXX each zero you add on requires exponentially more time.
- brainburn 13y agoI know the docs say it has to be a bunch of zeroes at the start, the actual test is whether or not the generated value is below a certain number.
- ars_technician 13y agoWhen you are looking at a binary number, the number of zeros at the start is the exact same thing as making sure the number is below a certain threshold.
- lololomg 13y agoNo it's not the exact same thing. Example: Treshold = 001010 If you check 001011 or 001001 then the number of leading zeros are the same but one number is below the threshold and the other is not.
- verroq 13y agoDoes there seriously need a Bitcoin article on HN every single day?
- Avalaxy 13y agoYes. It's one of the biggest online revolutions going on at the moment.
- baddox 13y agoThe biggest by far, I would argue.
- dmacedo 13y agoMaybe not as much, but I have to say that in regards to bitcoin, this is the most HN worthy link so far.
- jafaku 13y agoYou don't like programmable money? Ok, I'll try to post more CSS tricks and startups drama to make you feel more comfortable.
- logn 13y agoDon't forget psychology experiments and motivational advice. BTC is the most interesting thing since the Internet, IMO. Yeah, I'm tired of speculative 'is BTC going to fail' posts, but I love reading about all the new developments.
- rfnslyr 13y agoAbsolutely yes. Bitcoin is huge. If you don't like it, don't click it.
- mrb 13y agoMany people may not perceive the importance of Bitcoin, hence the need to educate the public about it. Decentralized digital currency really has the potential to profoundly change society, on the same scale as the Internet changed it. As Jeremy Allaire [1] put it: "global digital currency represents one of the most important technical and economic innovations of our time". [1] Multi-millionaire, creator of ColdFusion, CTO at Macromedia, now founded a $9 million-backed startup on Bitcoin (http://circle.com http://circle.com)
- aw3c2 13y agoRemotely related question: How do transactions get into the blockchain? Who manages the blockchain? Do others see the IP address(es) related to a transaction?
- VLM 13y agoSome of your questions are ambiguous. Like who is this who's looking at IP addrs and transactions and where's his protocol analyzer(s) deployed and ... This is probably the best place for you to start with these specific questions: https://en.bitcoin.it/wiki/Transactions https://en.bitcoin.it/wiki/Transactions or more generally https://en.bitcoin.it/wiki/Category:Technical https://en.bitcoin.it/wiki/Category:Technical
- deleted 13y ago[deleted]
- omegant 13y agoDoes somebody has an informed opinion about the skyrocketing of difficulty the next months?. What will happen when the top of the line ASICS will be mining at a loss in 4 to 5 months? Are new processors coming or the number of people mining will drop?
- jadeddrag 13y agoDon't forget that the USD/BTC price could also skyrocket to partially compensate for the difficulty increase.