Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/fnd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ var startCmd = &cobra.Command{
updateQueue.MaxLen = int32(cfg.Tuning.UpdateQueue.MaxLen)
updateQueue.MinUpdateInterval = config.ConvertDuration(cfg.Tuning.Timebank.MinUpdateIntervalMS, time.Millisecond)

updater := protocol.NewUpdater(mux, db, updateQueue, nameLocker, bs)
updater := protocol.NewUpdater(mux, db, updateQueue, nameLocker, bs, cfg.Tuning.Timebank)
updater.PollInterval = config.ConvertDuration(cfg.Tuning.Updater.PollIntervalMS, time.Millisecond)
updater.Workers = cfg.Tuning.Updater.Workers

Expand Down
12 changes: 7 additions & 5 deletions protocol/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ type Updater struct {
quitCh chan struct{}
wg sync.WaitGroup
lgr log.Logger
cfg config.TimebankConfig
}

func NewUpdater(mux *p2p.PeerMuxer, db *leveldb.DB, queue *UpdateQueue, nameLocker util.MultiLocker, bs blob.Store) *Updater {
func NewUpdater(mux *p2p.PeerMuxer, db *leveldb.DB, queue *UpdateQueue, nameLocker util.MultiLocker, bs blob.Store, cfg config.TimebankConfig) *Updater {
return &Updater{
PollInterval: config.ConvertDuration(config.DefaultConfig.Tuning.Updater.PollIntervalMS, time.Millisecond),
Workers: config.DefaultConfig.Tuning.Updater.Workers,
Expand All @@ -49,6 +50,7 @@ func NewUpdater(mux *p2p.PeerMuxer, db *leveldb.DB, queue *UpdateQueue, nameLock
obs: util.NewObservable(),
quitCh: make(chan struct{}),
lgr: log.WithModule("updater"),
cfg: cfg,
}
}

Expand Down Expand Up @@ -90,7 +92,7 @@ func (u *Updater) runWorker() {
BlobStore: u.bs,
Item: item,
}
if err := UpdateBlob(cfg); err != nil {
if err := UpdateBlob(cfg, u.cfg); err != nil {
u.obs.Emit("update:processed", item, err)
u.lgr.Error("error processing update", "name", item.Name, "err", err)
continue
Expand All @@ -111,7 +113,7 @@ type UpdateConfig struct {
Item *UpdateQueueItem
}

func UpdateBlob(cfg *UpdateConfig) error {
func UpdateBlob(cfg *UpdateConfig, timebankConfig config.TimebankConfig) error {
l := updaterLogger.Sub("name", cfg.Item.Name)
item := cfg.Item
defer item.Dispose()
Expand Down Expand Up @@ -197,8 +199,8 @@ func UpdateBlob(cfg *UpdateConfig) error {

newTimebank := CheckTimebank(&TimebankParams{
TimebankDuration: 48 * time.Hour,
MinUpdateInterval: 2 * time.Minute,
FullUpdatesPerPeriod: 2,
MinUpdateInterval: time.Duration(timebankConfig.MinUpdateIntervalMS),
FullUpdatesPerPeriod: timebankConfig.FullUpdatesPerPeriod,
}, prevUpdateTime, prevTimebank, payableSectorCount)
l.Debug(
"calculated new timebank",
Expand Down