Skip to content

Commit

Permalink
Merge pull request #109 from hyperledger/sql-logging
Browse files Browse the repository at this point in the history
Fix propagation of `blockNumber` to EVMConnect (and batch logging tweak)
  • Loading branch information
nguyer authored Feb 14, 2024
2 parents a085feb + 26834f1 commit 9e50b94
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
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

0 comments on commit 9e50b94

Please sign in to comment.