<p>It depends on the implementation. For Bitcoin Core, the node maintains a database which has the locations of all blocks on disk. If a block is deleted, then it will notice that the location of a block either does not exist or contains garbage or invalid data. If it does notice that a block is missing (or something is corrupted), it will attempt to rebuild the database using the blocks stored on disk and then download the missing blocks from its peers.</p>

<p>However, blocks can actually be deleted after they have been verified and the local database has updated so that the node knows the block it has just deleted was a valid block. This is called pruning, and with pruning, old, historical blocks can be deleted as they aren't used for anything in normal node operation (except helping new nodes sync).</p>

CC BY-SA 3.0
2017-07-05T13:56:36.157Z
Thanks @Andrew Chow, you mentioned "then it will notice that the location of a block either does not exist or contains garbage or invalid data", I am wondering how "it will notice". Is there a background thread on each peer that periodically checking the integrity of the blockchain, or the peer needs to scan through the blockchain for some reason?
Qi Zhang
CC BY-SA 3.0
2017-07-05T16:34:19.293Z
The node verifies integrity of its databases and of the blockchain on startup. I think you could delete blocks while it is running and it won't notice, but there will be an error next time it starts up.
Ava Chow
CC BY-SA 3.0
2017-07-05T03:43:52.103Z
2017-07-05T03:43:52.103Z
Ava Chow
<p>In the Bitcoin network, each peer maintains a full copy of the ledger (blockchain). What will happen if a peer losts one of its blocks in the blockchain (e.g. another process on the peer accidentally wiped out the disk area that stores the block)? Will this peer be able to detect that this block is missing? If yes, how will the peer detect it and how is it going to repair?</p>

<blockchain><synchronization><pruning>
What will happen if a block is lost on a peer?
Qi Zhang
# What will happen if a block is lost on a peer?

(Asked by: username_0 on 2017-07-05)

In the Bitcoin network, each peer maintains a full copy of the ledger (blockchain). What will happen if a peer losts one of its blocks in the blockchain (e.g. another process on the peer accidentally wiped out the disk area that stores the block)? Will this peer be able to detect that this block is missing? If yes, how will the peer detect it and how is it going to repair?

**Tags:** blockchain, synchronization, pruning


---

## 1 answers

### Answer by username_1 on 2017-07-05. Score: 4

It depends on the implementation. For Bitcoin Core, the node maintains a database which has the locations of all blocks on disk. If a block is deleted, then it will notice that the location of a block either does not exist or contains garbage or invalid data. If it does notice that a block is missing (or something is corrupted), it will attempt to rebuild the database using the blocks stored on disk and then download the missing blocks from its peers.

However, blocks can actually be deleted after they have been verified and the local database has updated so that the node knows the block it has just deleted was a valid block. This is called pruning, and with pruning, old, historical blocks can be deleted as they aren't used for anything in normal node operation (except helping new nodes sync).

> **Comments:**
> **username_0**: Thanks @Andrew username_1, you mentioned "then it will notice that the location of a block either does not exist or contains garbage or invalid data", I am wondering how "it will notice". Is there a background thread on each peer that periodically checking the integrity of the blockchain, or the peer needs to scan through the blockchain for some reason?  
> **username_1**: The node verifies integrity of its databases and of the blockchain on startup. I think you could delete blocks while it is running and it won't notice, but there will be an error next time it starts up.  

---

