algorand / algorand/go-algorand

Provide an option of how many last blocks to store

Open
#4,947 3 comments 0 reactions 0 assignees View on GitHub
new-feature-request Team Carbon-11
Dominant language
Go
Stars
1.4k
Forks
537
Avg merge
1d 6h
Merged PRs (30d)
17

Description

## Problem

Current implementation implies that you can only store last 1000 blocks or run an archive node storing all blocks to the first one.
This is the problem if you need specific amount of last blocks (e.g. 100000 or 10000) and don't want to store all blocks to save space.

## Solution

Provide an option to the algod daemon to specify how many blocks to store.

This should be very easy to fix, I'm not a go lang developer, but I've hard coded to save 10K blocks more by using this patch:

```
diff --git a/ledger/blockqueue.go b/ledger/blockqueue.go
index 4dfa1ae2..45ef5dd8 100644
--- a/ledger/blockqueue.go
+++ b/ledger/blockqueue.go
@@ -143,7 +143,7 @@ func (bq *blockQueue) syncer() {
bq.cond.Broadcast()
bq.mu.Unlock()

- minToSave := bq.l.notifyCommit(committed)
+ minToSave := bq.l.notifyCommit(committed) - 10000
bfstart := time.Now()
ledgerSyncBlockforgetCount.Inc(nil)
err = bq.l.blockDBs.Wdb.Atomic(func(ctx context.Context, tx *sql.Tx) error {
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.