Skip to content

Commit ceb9335

Browse files
committed
update
1 parent 176ff82 commit ceb9335

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

multinode/rpc_client_base.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ var errInvalidHead = errors.New("invalid head")
1717
const (
1818
rpcCallNameLatestBlock = "latest_block"
1919
rpcCallNameLatestFinalizedBlock = "latest_finalized_block"
20-
rpcMetricsDefaultIsSendOnly = false
2120
)
2221

2322
type RPCClientBaseConfig interface {
@@ -37,6 +36,7 @@ type RPCClientBase[HEAD Head] struct {
3736
log logger.Logger
3837
ctxTimeout time.Duration
3938
rpcURL string
39+
isSendOnly bool
4040
subsMu sync.RWMutex
4141
subs map[Subscription]struct{}
4242

@@ -65,13 +65,15 @@ func NewRPCClientBase[HEAD Head](
6565
latestBlock func(ctx context.Context) (HEAD, error),
6666
latestFinalizedBlock func(ctx context.Context) (HEAD, error),
6767
rpcURL string,
68+
isSendOnly bool,
6869
rpcMetrics frameworkmetrics.RPCClientMetrics,
6970
) *RPCClientBase[HEAD] {
7071
base := &RPCClientBase[HEAD]{
7172
cfg: cfg,
7273
log: log,
7374
ctxTimeout: ctxTimeout,
7475
rpcURL: rpcURL,
76+
isSendOnly: isSendOnly,
7577
latestBlock: latestBlock,
7678
latestFinalizedBlock: latestFinalizedBlock,
7779
subs: make(map[Subscription]struct{}),
@@ -216,7 +218,7 @@ func (m *RPCClientBase[HEAD]) recordRPCRequest(ctx context.Context, callName str
216218
return
217219
}
218220

219-
m.rpcMetrics.RecordRequest(ctx, m.rpcURL, rpcMetricsDefaultIsSendOnly, callName, time.Since(startedAt), err)
221+
m.rpcMetrics.RecordRequest(ctx, m.rpcURL, m.isSendOnly, callName, time.Since(startedAt), err)
220222
}
221223

222224
func (m *RPCClientBase[HEAD]) OnNewHead(ctx context.Context, requestCh <-chan struct{}, head HEAD) {

multinode/rpc_client_base_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func newTestRPC(t *testing.T) *testRPC {
6868
}
6969

7070
rpc := &testRPC{}
71-
rpc.RPCClientBase = NewRPCClientBase[*testHead](cfg, requestTimeout, lggr, rpc.latestBlock, rpc.latestBlock, "http://localhost:8545", nil)
71+
rpc.RPCClientBase = NewRPCClientBase[*testHead](cfg, requestTimeout, lggr, rpc.latestBlock, rpc.latestBlock, "http://localhost:8545", false, nil)
7272
t.Cleanup(rpc.Close)
7373
return rpc
7474
}
@@ -163,6 +163,7 @@ func TestRPCClientBase_RecordsRPCMetrics(t *testing.T) {
163163
return &testHead{blockNumber: 8}, nil
164164
},
165165
testURL,
166+
false,
166167
spy,
167168
)
168169

@@ -192,6 +193,7 @@ func TestRPCClientBase_RecordsRPCMetrics(t *testing.T) {
192193
return nil, expectedErr
193194
},
194195
testURL,
196+
false,
195197
spy,
196198
)
197199

@@ -219,6 +221,7 @@ func TestRPCClientBase_RecordsRPCMetrics(t *testing.T) {
219221
return &testHead{blockNumber: 8}, nil
220222
},
221223
testURL,
224+
false,
222225
spy,
223226
)
224227

0 commit comments

Comments
 (0)