Add a service (v3) to fill indexing gap for watched addresses #149

Merged
ashwinphatak merged 16 commits from ng-watched-addresses-v3 into master 2022-05-18 08:54:04 +00:00
2 changed files with 59 additions and 33 deletions
Showing only changes of commit c8bdaefe97 - Show all commits

View File

@ -101,9 +101,11 @@ func serve() {
logWithCommand.Info("state validator disabled")
}
var watchedAddressFillService *fill.Service
if serverConfig.WatchedAddressGapFillerEnabled {
service := fill.New(serverConfig)
go service.Start()
watchedAddressFillService = fill.New(serverConfig)
wg.Add(1)
go watchedAddressFillService.Start(wg)
logWithCommand.Info("watched address gap filler enabled")
} else {
logWithCommand.Info("watched address gap filler disabled")
@ -115,6 +117,9 @@ func serve() {
if graphQL != nil {
graphQL.Stop()
}
if watchedAddressFillService != nil {
watchedAddressFillService.Stop()
}
server.Stop()
wg.Wait()
}

View File

@ -19,6 +19,7 @@ package fill
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
import (
"math"
"strings"
"sync"
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
"time"
"github.com/ethereum/go-ethereum/common"
@ -46,6 +47,7 @@ type Service struct {
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
db *sqlx.DB
client *rpc.Client
interval int
quitChan chan bool
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
}
// NewServer creates a new Service
@ -54,12 +56,32 @@ func New(config *serve.Config) *Service {
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
db: config.DB,
client: config.Client,
interval: config.WatchedAddressGapFillInterval,
quitChan: make(chan bool),
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
}
}
// Start is used to begin the service
func (s *Service) Start() {
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
func (s *Service) Start(wg *sync.WaitGroup) {
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
defer wg.Done()
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
for {
select {
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
case <-s.quitChan:
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
log.Info("quiting eth ipld server process")
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
return
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
default:
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
s.fill()
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
}
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
}
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
}
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
// Stop is used to gracefully stop the service
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
func (s *Service) Stop() {
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
log.Info("stopping watched address gap filler")
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
close(s.quitChan)
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
}
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
// fill performs the filling of indexing gap for watched addresses
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
func (s *Service) fill() {
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
// Wait for specified interval duration
time.Sleep(time.Duration(s.interval) * time.Second)
@ -98,7 +120,6 @@ func (s *Service) Start() {
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
s.UpdateLastFilledAt(blockNumber, fillAddresses)
}
}
}
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
}
// GetFillAddresses finds the encompassing range to perform fill for the given watched addresses

Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.
Review

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.

If this is a standalone background process that has no server component and is disconnected from the rest of ipld-eth-server I'm not sure it belongs in this repo.