Skip to content

Commit

Permalink
pkg/loop/internal: remove CL_DATASOURCE_OVERTIME (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Dec 14, 2023
1 parent b6c433e commit f53e314
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions pkg/loop/internal/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,15 @@ package internal
import (
"context"
"math/big"
"os"
"time"

"google.golang.org/grpc"

"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink-common/pkg/loop/internal/pb"
"github.com/smartcontractkit/chainlink-common/pkg/utils"
)

// github.com/smartcontractkit/libocr/offchainreporting2plus/internal/protocol.ReportingPluginTimeoutWarningGracePeriod
var datasourceOvertime = 100 * time.Millisecond

func init() {
// undocumented escape hatch
// TODO: remove with https://smartcontract-it.atlassian.net/browse/BCF-2209
if v := os.Getenv("CL_DATASOURCE_OVERTIME"); v != "" {
d, err := time.ParseDuration(v)
if err == nil {
datasourceOvertime = d
}
}
}

var _ median.DataSource = (*dataSourceClient)(nil)

type dataSourceClient struct {
Expand Down Expand Up @@ -58,17 +41,6 @@ type dataSourceServer struct {
}

func (d *dataSourceServer) Observe(ctx context.Context, request *pb.ObserveRequest) (*pb.ObserveReply, error) {
// Pipeline observations may return results after the context is cancelled, so we modify the
// deadline to give them time to return before the parent context deadline.
// TODO: remove with https://smartcontract-it.atlassian.net/browse/BCF-2209
var cancel func()
ctx, cancel = utils.ContextWithDeadlineFn(ctx, func(orig time.Time) time.Time {
if tenPct := time.Until(orig) / 10; datasourceOvertime > tenPct {
return orig.Add(-tenPct)
}
return orig.Add(-datasourceOvertime)
})
defer cancel()
timestamp, err := reportTimestamp(request.ReportTimestamp)
if err != nil {
return nil, err
Expand Down

0 comments on commit f53e314

Please sign in to comment.