A local snapshot is the process in which an IRI node records the state of its ledger at a given time.
Snapshot files contain data about milestone transactions and normal transactions that an IRI node has already seen. When an IRI node restarts or starts running, it can read these files and use the transactions as a starting point for synchronizing its ledger with its neighbors.
The benefits of doing a local snapshot are the following:
- If an IRI node restarts for any reason, it can synchronize its ledger with neighbor IRI nodes faster than without doing a local snapshot
- If an IRI node's ledger becomes too large, it can use the snapshot files to delete any old transactions
Note: Local snapshots are available only in version 1.6.0 and higher of the IRI.
To synchronize with the network, IRI nodes use a starting point to request every confirmed transaction and milestone transaction from their neighbors, validate the transactions, and append them to their ledgers.
The starting point for requesting transactions from neighbors affects the speed at which an IRI node will synchronize.
Without snapshot files, an IRI node would start from the milestone in the
startMilestoneIndexvariable is hard-coded into each version of the IRI.)
With snapshot files, an IRI node would synchronize its ledger from the milestones in the snapshot.meta file. Therefore, as long as an IRI node creates regular local snapshots, this process decreases the time it takes for an IRI node to synchronize.
An IRI node can use the snapshot files to delete old transactions from its ledger.
Over time, the ledger of an IRI node accumulates many valid transactions, which often cause the ledger size to become larger than the IRI node's available memory. To stop the ledger from becoming too large, you can choose to create local snapshots at regular intervals. This option is enabled by default in the
Transactions are deleted only if they come before a milestone transaction that is older than the sum of the following calculation: