forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
31 lines (25 loc) · 828 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package reap contains the history reaping subsystem for horizon. This system
// is designed to remove data from the history database such that it does not
// grow indefinitely. The system can be configured with a number of ledgers to
// maintain at a minimum.
package reap
import (
"time"
"github.com/stellar/go/support/db"
)
// System represents the history reaping subsystem of horizon.
type System struct {
HorizonDB *db.Session
RetentionCount uint
nextRun time.Time
}
// New initializes the reaper, causing it to begin polling the stellar-core
// database for now ledgers and ingesting data into the horizon database.
func New(retention uint, horizon *db.Session) *System {
r := &System{
HorizonDB: horizon,
RetentionCount: retention,
}
r.nextRun = time.Now().Add(1 * time.Hour)
return r
}