Skip to content

Commit

Permalink
Merge pull request #9 from Alethio/fix-http-polling
Browse files Browse the repository at this point in the history
Fix for issue #8.
  • Loading branch information
kwix authored Dec 2, 2019
2 parents 11a3936 + 1edba7e commit fa48d85
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var runCmd = &cobra.Command{
BestBlockTracker: bestblock.Config{
NodeURL: viper.GetString("eth.client.http"),
NodeURLWS: viper.GetString("eth.client.ws"),
PollInterval: viper.GetDuration("eth.poll-interval"),
PollInterval: viper.GetDuration("eth.client.poll-interval"),
},
TaskManager: taskmanager.Config{
RedisServer: viper.GetString("redis.server"),
Expand Down
4 changes: 2 additions & 2 deletions eth/bestblock/bestblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ func (b *Tracker) Run() {
log.Info("starting best block tracker")

for {
log.Info("setting up websocket connection")

var conn *ethrpc.ETH
var err error

if b.config.NodeURLWS != "" {
log.Info("setting up websocket connection")
conn, err = ethrpc.NewWithDefaults(b.config.NodeURLWS)
} else {
log.Info("setting up best block polling")
conn, err = ethrpc.NewWithDefaults(b.config.NodeURL)
}
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions eth/bestblock/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "time"

// runHTTP polls the node for the best block number every [config.PollInterval]
func (b *Tracker) runHTTP() {
log.Tracef("tracking best block via HTTP polling, every %s", b.config.PollInterval)
for {
select {
case <-time.Tick(b.config.PollInterval):
Expand Down

0 comments on commit fa48d85

Please sign in to comment.