Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix propagation of blockNumber to EVMConnect (and batch logging tweak) #109

Merged
merged 2 commits into from
Feb 14, 2024
Merged
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
6 changes: 4 additions & 2 deletions internal/persistence/postgres/transaction_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type transactionWriter struct {

type transactionWriterBatch struct {
id string
opened time.Time
ops []*transactionOperation
timeoutContext context.Context
timeoutCancel func()
Expand Down Expand Up @@ -207,7 +208,8 @@ func (tw *transactionWriter) worker(i int) {
}
if batch == nil {
batch = &transactionWriterBatch{
id: fmt.Sprintf("%.4d_%.9d", i, batchCount),
id: fmt.Sprintf("%.4d_%.9d", i, batchCount),
opened: time.Now(),
}
batch.timeoutContext, batch.timeoutCancel = context.WithTimeout(ctx, tw.batchTimeout)
batchCount++
Expand All @@ -226,7 +228,7 @@ func (tw *transactionWriter) worker(i int) {

if batch != nil && (timedOut || (len(batch.ops) >= tw.batchMaxSize)) {
batch.timeoutCancel()
l.Debugf("Running batch %s (len=%d)", batch.id, len(batch.ops))
l.Debugf("Running batch %s (len=%d,timeout=%t,age=%dms)", batch.id, len(batch.ops), timedOut, time.Since(batch.opened).Milliseconds())
tw.runBatch(ctx, batch)
batch = nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/apitypes/query_request.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -24,6 +24,7 @@ import (
type QueryRequest struct {
Headers RequestHeaders `json:"headers"`
ffcapi.TransactionInput
BlockNumber *string `json:"blockNumber,omitempty"`
}

// QueryResponse is the response payload for a query
Expand Down
4 changes: 2 additions & 2 deletions pkg/ffcapi/method_call.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -28,7 +28,7 @@ import (
// detected by the back-end connector.
type QueryInvokeRequest struct {
TransactionInput
BlockNumber *fftypes.FFBigInt `json:"blockNumber,omitempty"`
BlockNumber *string `json:"blockNumber,omitempty"`
}

type QueryInvokeResponse struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/fftm/route__root_command.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -101,6 +101,7 @@ var postRootCommand = func(m *manager) *ffapi.Route {
}
res, _, err := m.connector.QueryInvoke(r.Req.Context(), &ffcapi.QueryInvokeRequest{
TransactionInput: tReq.TransactionInput,
BlockNumber: tReq.BlockNumber,
})
if err != nil {
return nil, err
Expand Down