Bitcoin Forum
December 13, 2024, 04:10:20 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What stops short forks from taking up everyone's disk space?  (Read 853 times)
interfect (OP)
Full Member
***
Offline Offline

Activity: 141
Merit: 100


View Profile
June 29, 2013, 10:42:28 PM
 #1

I'm working on my own generic blockchain implementation, and I have a question about how Bitcoin ensures that everyone doesn't need to remember every fork that ever happened.

The longest chain always wins out, in the sense that that's the chain that the client looks at to see who has how many Bitcoins. But if I start getting blocks that fork off my current longest chain several blocks back, I need to keep those blocks around in case they end up forming a chain longer than the one I'm on. And there's no guarantee that I won't get half the blocks in this new longest chain today, and half tomorrow, so when I shut down my client, those blocks in the currently-shorter chain need to be saved to disk.

What stops those blocks from needing to be kept around indefinitely?

If the blocks do need to be kept around indefinitely in case their fork becomes the longest chain, what stops someone from solving a large number of blocks forking off some early, low-difficulty point in the chain, and taking up lots of disk space with all these forks?
tomcollins
Full Member
***
Offline Offline

Activity: 182
Merit: 101


View Profile
June 30, 2013, 12:16:11 AM
 #2

Why do you need to keep them?  The only reason a fork could return is if someone thought it was the best chain and kept working on it.  This means they would have all of this information, which should be retrievable.    You need to catch up anyway if you disconnect from the network and return in an hour, this seems like it would be the same case.  You keep track of what you think is the best chain, if someone gives you evidence of a better one, you replace what you know with what they give you.
piotr_n
Legendary
*
Offline Offline

Activity: 2058
Merit: 1416


aka tonikt


View Profile WWW
July 01, 2013, 06:16:16 PM
 #3

What stops those blocks from needing to be kept around indefinitely?
Nothing. Once you store a block on disk, it will stay there forever - that's the most common implementation.
But you should note that mining blocks consts money, so people won't do this just to eat up your disk space - they prefer to mine a new block to earn 25BTC.

They can though try to create branches forking at low block numbers (where the difficulty is low), but most clients won't accept such an old blocks, so they won't store them in disk neither.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
cp1
Hero Member
*****
Offline Offline

Activity: 616
Merit: 500


Stop using branwallets


View Profile
July 01, 2013, 06:19:02 PM
 #4

There's checkpoints saved every so often, so you can't go past the latest checkpoint.

Guide to armory offline install on USB key:  https://bitcointalk.org/index.php?topic=241730.0
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1026



View Profile
July 02, 2013, 12:23:25 PM
 #5

Each node does not need to seek out and download every fork, only ones that might matter.

Only shallow forks might become important, but they are also expensive to create.  Deep forks are cheap, but will never win and can be ignored.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
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!