go-algorand
go-algorand copied to clipboard
Provide an option of how many last blocks to store
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 {
Hi team!
It's been awhile since I've requested this feature. Any update on this?
Should be a trivial to implement.
@jsgranados I have the same problem, is it possible to provide a parameter to support this feature
@jsgranados I have the same problem, is it possible to provide a parameter to support this feature
I believe you can use MaxBlockHistoryLookback in your config.json to specify a number of rounds you want your algod node to retain, although I've not seen this used beyond a few thousand.
https://github.com/algorand/go-algorand/blob/master/config/localTemplate.go#L560
// BlockHistoryLookback sets the max lookback range for block information.
// i.e. the block DB can return transaction IDs for questions for the range Latest-MaxBlockHistoryLookback...Latest
MaxBlockHistoryLookback uint64 `version[31]:"0"`