Skip to content

Commit 9e50b94

Browse files
authored
Merge pull request #109 from hyperledger/sql-logging
Fix propagation of `blockNumber` to EVMConnect (and batch logging tweak)
2 parents a085feb + 26834f1 commit 9e50b94

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

internal/persistence/postgres/transaction_writer.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ type transactionWriter struct {
7878

7979
type transactionWriterBatch struct {
8080
id string
81+
opened time.Time
8182
ops []*transactionOperation
8283
timeoutContext context.Context
8384
timeoutCancel func()
@@ -207,7 +208,8 @@ func (tw *transactionWriter) worker(i int) {
207208
}
208209
if batch == nil {
209210
batch = &transactionWriterBatch{
210-
id: fmt.Sprintf("%.4d_%.9d", i, batchCount),
211+
id: fmt.Sprintf("%.4d_%.9d", i, batchCount),
212+
opened: time.Now(),
211213
}
212214
batch.timeoutContext, batch.timeoutCancel = context.WithTimeout(ctx, tw.batchTimeout)
213215
batchCount++
@@ -226,7 +228,7 @@ func (tw *transactionWriter) worker(i int) {
226228

227229
if batch != nil && (timedOut || (len(batch.ops) >= tw.batchMaxSize)) {
228230
batch.timeoutCancel()
229-
l.Debugf("Running batch %s (len=%d)", batch.id, len(batch.ops))
231+
l.Debugf("Running batch %s (len=%d,timeout=%t,age=%dms)", batch.id, len(batch.ops), timedOut, time.Since(batch.opened).Milliseconds())
230232
tw.runBatch(ctx, batch)
231233
batch = nil
232234
}

pkg/apitypes/query_request.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2022 Kaleido, Inc.
1+
// Copyright © 2024 Kaleido, Inc.
22
//
33
// SPDX-License-Identifier: Apache-2.0
44
//
@@ -24,6 +24,7 @@ import (
2424
type QueryRequest struct {
2525
Headers RequestHeaders `json:"headers"`
2626
ffcapi.TransactionInput
27+
BlockNumber *string `json:"blockNumber,omitempty"`
2728
}
2829

2930
// QueryResponse is the response payload for a query

pkg/ffcapi/method_call.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2022 Kaleido, Inc.
1+
// Copyright © 2024 Kaleido, Inc.
22
//
33
// SPDX-License-Identifier: Apache-2.0
44
//
@@ -28,7 +28,7 @@ import (
2828
// detected by the back-end connector.
2929
type QueryInvokeRequest struct {
3030
TransactionInput
31-
BlockNumber *fftypes.FFBigInt `json:"blockNumber,omitempty"`
31+
BlockNumber *string `json:"blockNumber,omitempty"`
3232
}
3333

3434
type QueryInvokeResponse struct {

pkg/fftm/route__root_command.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2023 Kaleido, Inc.
1+
// Copyright © 2024 Kaleido, Inc.
22
//
33
// SPDX-License-Identifier: Apache-2.0
44
//
@@ -101,6 +101,7 @@ var postRootCommand = func(m *manager) *ffapi.Route {
101101
}
102102
res, _, err := m.connector.QueryInvoke(r.Req.Context(), &ffcapi.QueryInvokeRequest{
103103
TransactionInput: tReq.TransactionInput,
104+
BlockNumber: tReq.BlockNumber,
104105
})
105106
if err != nil {
106107
return nil, err

0 commit comments

Comments
 (0)