Skip to content

Commit

Permalink
Merge pull request #117 from kaleido-io/pass-in-action-occurred-time
Browse files Browse the repository at this point in the history
Pass in action occurred time
  • Loading branch information
Chengxuan authored May 22, 2024
2 parents af4a223 + cc68a9c commit 0b9557f
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 100 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ test: deps lint
coverage.html:
$(VGO) tool cover -html=coverage.txt
coverage: test coverage.html
lint: ${LINT}
lint:
$(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2
GOGC=20 $(LINT) run -v --timeout 5m

${MOCKERY}:
$(VGO) install github.com/vektra/mockery/v2@latest
${LINT}:
$(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2


define makemock
mocks: mocks-$(strip $(1))-$(strip $(2))
Expand Down
28 changes: 14 additions & 14 deletions internal/persistence/leveldb/leveldb_persistence.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 @@ -661,7 +661,7 @@ func (p *leveldbPersistence) DeleteTransaction(ctx context.Context, txID string)
)
}

func (p *leveldbPersistence) setSubStatusInStruct(ctx context.Context, tx *apitypes.TXWithStatus, subStatus apitypes.TxSubStatus) {
func (p *leveldbPersistence) setSubStatusInStruct(ctx context.Context, tx *apitypes.TXWithStatus, subStatus apitypes.TxSubStatus, actionOccurred *fftypes.FFTime) {

// See if the status being transitioned to is the same as the current status.
// If so, there's nothing to do.
Expand All @@ -674,7 +674,7 @@ func (p *leveldbPersistence) setSubStatusInStruct(ctx context.Context, tx *apity

// If this is a change in status add a new record
newStatus := &apitypes.TxHistoryStateTransitionEntry{
Time: fftypes.Now(),
Time: actionOccurred,
Status: subStatus,
Actions: make([]*apitypes.TxHistoryActionEntry, 0),
}
Expand All @@ -692,16 +692,16 @@ func (p *leveldbPersistence) setSubStatusInStruct(ctx context.Context, tx *apity
for _, statusType := range tx.DeprecatedHistorySummary {
if statusType.Status == subStatus {
// Just increment the counter and last timestamp
statusType.LastOccurrence = fftypes.Now()
statusType.LastOccurrence = actionOccurred
statusType.Count++
return
}
}

tx.DeprecatedHistorySummary = append(tx.DeprecatedHistorySummary, &apitypes.TxHistorySummaryEntry{Status: subStatus, Count: 1, FirstOccurrence: fftypes.Now(), LastOccurrence: fftypes.Now()})
tx.DeprecatedHistorySummary = append(tx.DeprecatedHistorySummary, &apitypes.TxHistorySummaryEntry{Status: subStatus, Count: 1, FirstOccurrence: actionOccurred, LastOccurrence: actionOccurred})
}

func (p *leveldbPersistence) AddSubStatusAction(ctx context.Context, txID string, subStatus apitypes.TxSubStatus, action apitypes.TxAction, info *fftypes.JSONAny, errInfo *fftypes.JSONAny) error {
func (p *leveldbPersistence) AddSubStatusAction(ctx context.Context, txID string, subStatus apitypes.TxSubStatus, action apitypes.TxAction, info *fftypes.JSONAny, errInfo *fftypes.JSONAny, actionOccurred *fftypes.FFTime) error {

tx, err := p.getPersistedTX(ctx, txID)
if err != nil {
Expand All @@ -713,7 +713,7 @@ func (p *leveldbPersistence) AddSubStatusAction(ctx context.Context, txID string
}

// Ensure structure is updated to latest sub status
p.setSubStatusInStruct(ctx, tx, subStatus)
p.setSubStatusInStruct(ctx, tx, subStatus, actionOccurred)

// See if this action exists in the list already since we only want to update the single entry, not
// add a new one
Expand All @@ -723,11 +723,11 @@ func (p *leveldbPersistence) AddSubStatusAction(ctx context.Context, txID string
if entry.Action == action {
alreadyRecordedAction = true
entry.OccurrenceCount++
entry.LastOccurrence = fftypes.Now()
entry.LastOccurrence = actionOccurred

if errInfo != nil {
entry.LastError = persistence.JSONOrString(errInfo)
entry.LastErrorTime = fftypes.Now()
entry.LastErrorTime = actionOccurred
}

if info != nil {
Expand All @@ -740,15 +740,15 @@ func (p *leveldbPersistence) AddSubStatusAction(ctx context.Context, txID string
if !alreadyRecordedAction {
// If this is an entirely new action for this status entry, add it to the list
newAction := &apitypes.TxHistoryActionEntry{
Time: fftypes.Now(),
Time: actionOccurred,
Action: action,
LastOccurrence: fftypes.Now(),
LastOccurrence: actionOccurred,
OccurrenceCount: 1,
}

if errInfo != nil {
newAction.LastError = persistence.JSONOrString(errInfo)
newAction.LastErrorTime = fftypes.Now()
newAction.LastErrorTime = actionOccurred
}

if info != nil {
Expand All @@ -763,14 +763,14 @@ func (p *leveldbPersistence) AddSubStatusAction(ctx context.Context, txID string
for _, actionType := range tx.DeprecatedHistorySummary {
if actionType.Action == action {
// Just increment the counter and last timestamp
actionType.LastOccurrence = fftypes.Now()
actionType.LastOccurrence = actionOccurred
actionType.Count++
found = true
break
}
}
if !found {
tx.DeprecatedHistorySummary = append(tx.DeprecatedHistorySummary, &apitypes.TxHistorySummaryEntry{Action: action, Count: 1, FirstOccurrence: fftypes.Now(), LastOccurrence: fftypes.Now()})
tx.DeprecatedHistorySummary = append(tx.DeprecatedHistorySummary, &apitypes.TxHistorySummaryEntry{Action: action, Count: 1, FirstOccurrence: actionOccurred, LastOccurrence: actionOccurred})
}
return p.writeTransaction(ctx, tx, false)
}
Expand Down
44 changes: 22 additions & 22 deletions internal/persistence/leveldb/leveldb_persistence_test.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 @@ -460,7 +460,7 @@ func TestAddSubStatusActionFail(t *testing.T) {

tx := newTestTX("0x1234", apitypes.TxStatusPending)

err := p.AddSubStatusAction(ctx, tx.ID, apitypes.TxSubStatusTracking, apitypes.TxActionAssignNonce, nil, nil)
err := p.AddSubStatusAction(ctx, tx.ID, apitypes.TxSubStatusTracking, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.Error(t, err)

}
Expand Down Expand Up @@ -834,7 +834,7 @@ func TestManagedTXSubStatus(t *testing.T) {
// Adding the same sub-status lots of times in succession should only result
// in a single entry for that instance
for i := 0; i < 100; i++ {
err := p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil)
err := p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.NoError(t, err)
}

Expand All @@ -845,7 +845,7 @@ func TestManagedTXSubStatus(t *testing.T) {

// Adding a different type of sub-status should result in
// a new entry in the list
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusTracking, apitypes.TxActionAssignNonce, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusTracking, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.NoError(t, err)

txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
Expand All @@ -855,9 +855,9 @@ func TestManagedTXSubStatus(t *testing.T) {
// Even if many new types are added we shouldn't go over the
// configured upper limit
for i := 0; i < 100; i++ {
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusStale, apitypes.TxActionAssignNonce, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusStale, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.NoError(t, err)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusTracking, apitypes.TxActionAssignNonce, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusTracking, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.NoError(t, err)
}

Expand All @@ -875,22 +875,22 @@ func TestManagedTXSubStatusRepeat(t *testing.T) {
assert.NoError(t, err)

// Add a sub-status
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.NoError(t, err)
txh, err := p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
assert.Equal(t, 1, len(txh.History))
assert.Equal(t, 2, len(txh.DeprecatedHistorySummary))

// Add another sub-status
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusTracking, apitypes.TxActionSubmitTransaction, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusTracking, apitypes.TxActionSubmitTransaction, nil, nil, fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.Equal(t, 2, len(txh.History))
assert.Equal(t, 4, len(txh.DeprecatedHistorySummary))

// Add another that we've seen before
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, nil, fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.Equal(t, 3, len(txh.History)) // This goes up
Expand All @@ -902,30 +902,30 @@ func TestManagedTXSubStatusAction(t *testing.T) {
defer done()
mtx := newTestTX("0x12345", apitypes.TxStatusPending)

err := p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil)
err := p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.Regexp(t, "FF21067", err)

err = p.InsertTransactionWithNextNonce(ctx, mtx, func(ctx context.Context, signer string) (uint64, error) { return 12345, nil })
assert.NoError(t, err)

// Add an action
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.NoError(t, err)
txh, err := p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
assert.Equal(t, 1, len(txh.History[0].Actions))
assert.Nil(t, txh.History[0].Actions[0].LastErrorTime)

// Add another action
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionRetrieveGasPrice, nil, fftypes.JSONAnyPtr(`{"gasError":"Acme Gas Oracle RC=12345"}`))
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionRetrieveGasPrice, nil, fftypes.JSONAnyPtr(`{"gasError":"Acme Gas Oracle RC=12345"}`), fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
assert.Equal(t, 2, len(txh.History[0].Actions))
assert.Equal(t, (*txh.History[0].Actions[1].LastError).String(), `{"gasError":"Acme Gas Oracle RC=12345"}`)

// Add the same action which should cause the previous one to inc its counter
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionRetrieveGasPrice, fftypes.JSONAnyPtr(`{"info":"helloworld"}`), fftypes.JSONAnyPtr(`{"error":"nogood"}`))
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionRetrieveGasPrice, fftypes.JSONAnyPtr(`{"info":"helloworld"}`), fftypes.JSONAnyPtr(`{"error":"nogood"}`), fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
Expand All @@ -934,7 +934,7 @@ func TestManagedTXSubStatusAction(t *testing.T) {
assert.Equal(t, 2, txh.History[0].Actions[1].OccurrenceCount)

// Add the same action but with new error information should update the last error field
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionRetrieveGasPrice, nil, fftypes.JSONAnyPtr(`{"gasError":"Acme Gas Oracle RC=67890"}`))
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionRetrieveGasPrice, nil, fftypes.JSONAnyPtr(`{"gasError":"Acme Gas Oracle RC=67890"}`), fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
Expand All @@ -944,7 +944,7 @@ func TestManagedTXSubStatusAction(t *testing.T) {

// Add a new type of action
reason := "known_transaction"
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, fftypes.JSONAnyPtr(`{"reason":"`+reason+`"}`), nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, fftypes.JSONAnyPtr(`{"reason":"`+reason+`"}`), nil, fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
Expand All @@ -956,7 +956,7 @@ func TestManagedTXSubStatusAction(t *testing.T) {
// Add one more type of action

receiptId := "123456"
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionReceiveReceipt, fftypes.JSONAnyPtr(`{"receiptId":"`+receiptId+`"}`), nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionReceiveReceipt, fftypes.JSONAnyPtr(`{"receiptId":"`+receiptId+`"}`), nil, fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
Expand All @@ -972,13 +972,13 @@ func TestManagedTXSubStatusAction(t *testing.T) {

// Add some new sub-status and actions to check max lengths are correct
// Seen one of these before - should increase summary length by 1
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusConfirmed, apitypes.TxActionReceiveReceipt, fftypes.JSONAnyPtr(`{"receiptId":"`+receiptId+`"}`), nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusConfirmed, apitypes.TxActionReceiveReceipt, fftypes.JSONAnyPtr(`{"receiptId":"`+receiptId+`"}`), nil, fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.Equal(t, 6, len(txh.DeprecatedHistorySummary))

// Seen both of these before - no change expected
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.NoError(t, err)
txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
Expand Down Expand Up @@ -1070,7 +1070,7 @@ func TestManagedTXSubStatusInvalidJSON(t *testing.T) {
reason := "\"cannot-marshall\""

// Add a new type of action
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, fftypes.JSONAnyPtr(`{"reason":"`+reason+`"}`), nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, fftypes.JSONAnyPtr(`{"reason":"`+reason+`"}`), nil, fftypes.Now())
assert.NoError(t, err)
txh, err := p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
assert.NoError(t, err)
Expand All @@ -1095,7 +1095,7 @@ func TestManagedTXSubStatusMaxEntries(t *testing.T) {
// first 50
for i := 0; i < 100; i++ {
nextSubStatus = apitypes.TxSubStatus(fmt.Sprint(i))
p.AddSubStatusAction(ctx, mtx.ID, nextSubStatus, apitypes.TxActionAssignNonce, nil, nil)
p.AddSubStatusAction(ctx, mtx.ID, nextSubStatus, apitypes.TxActionAssignNonce, nil, nil, fftypes.Now())
assert.NoError(t, err)
}

Expand All @@ -1114,7 +1114,7 @@ func TestMaxHistoryCountSetToZero(t *testing.T) {
err := p.InsertTransactionWithNextNonce(ctx, mtx, func(ctx context.Context, signer string) (uint64, error) { return 12345, nil })
assert.NoError(t, err)

err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, nil, fftypes.Now())
assert.NoError(t, err)

txh, err := p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
Expand All @@ -1141,7 +1141,7 @@ func TestAddReceivedStatusWhenNothingSet(t *testing.T) {
assert.NoError(t, err)
assert.Nil(t, txh.History)

err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, nil)
err = p.AddSubStatusAction(ctx, mtx.ID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, nil, fftypes.Now())
assert.NoError(t, err)

txh, err = p.GetTransactionByIDWithStatus(ctx, mtx.ID, true)
Expand Down
10 changes: 5 additions & 5 deletions internal/persistence/postgres/transactions_test.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 @@ -103,13 +103,13 @@ func TestTransactionBasicValidationPSQL(t *testing.T) {
assert.NoError(t, err)

// A couple of transaction history entries
err = p.AddSubStatusAction(ctx, txID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, fftypes.JSONAnyPtr(`{"nonce":"11111"}`), nil)
err = p.AddSubStatusAction(ctx, txID, apitypes.TxSubStatusReceived, apitypes.TxActionAssignNonce, fftypes.JSONAnyPtr(`{"nonce":"11111"}`), nil, fftypes.Now())
assert.NoError(t, err)
err = p.AddSubStatusAction(ctx, txID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, fftypes.JSONAnyPtr(`"failed to submit 1"`))
err = p.AddSubStatusAction(ctx, txID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, fftypes.JSONAnyPtr(`"failed to submit 1"`), fftypes.Now())
assert.NoError(t, err)
err = p.AddSubStatusAction(ctx, txID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, fftypes.JSONAnyPtr(`"failed to submit 2"`))
err = p.AddSubStatusAction(ctx, txID, apitypes.TxSubStatusReceived, apitypes.TxActionSubmitTransaction, nil, fftypes.JSONAnyPtr(`"failed to submit 2"`), fftypes.Now())
assert.NoError(t, err)
err = p.AddSubStatusAction(ctx, txID, apitypes.TxSubStatusTracking, apitypes.TxActionSubmitTransaction, fftypes.JSONAnyPtr(`{"txhash":"0x12345"}`), nil)
err = p.AddSubStatusAction(ctx, txID, apitypes.TxSubStatusTracking, apitypes.TxActionSubmitTransaction, fftypes.JSONAnyPtr(`{"txhash":"0x12345"}`), nil, fftypes.Now())
assert.NoError(t, err)

// Finally the update - do a comprehensive one
Expand Down
12 changes: 6 additions & 6 deletions internal/persistence/postgres/txhistory.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 @@ -95,25 +95,25 @@ func (p *sqlPersistence) ListTransactionHistory(ctx context.Context, txID string
return p.txHistory.GetMany(ctx, filter.Condition(filter.Builder().Eq("transaction", txID)))
}

func (p *sqlPersistence) AddSubStatusAction(ctx context.Context, txID string, subStatus apitypes.TxSubStatus, action apitypes.TxAction, info *fftypes.JSONAny, errInfo *fftypes.JSONAny) error {
func (p *sqlPersistence) AddSubStatusAction(ctx context.Context, txID string, subStatus apitypes.TxSubStatus, action apitypes.TxAction, info *fftypes.JSONAny, errInfo *fftypes.JSONAny, actionOccurred *fftypes.FFTime) error {
// Dispatch to TX writer
now := fftypes.Now()

op := newTransactionOperation(txID)
op.historyRecord = &apitypes.TXHistoryRecord{
ID: fftypes.NewUUID(),
TransactionID: txID,
SubStatus: subStatus,
TxHistoryActionEntry: apitypes.TxHistoryActionEntry{
OccurrenceCount: 1,
Time: now,
LastOccurrence: now,
Time: actionOccurred,
LastOccurrence: actionOccurred,
Action: action,
LastInfo: persistence.JSONOrString(info), // guard against bad JSON
LastError: persistence.JSONOrString(errInfo), // guard against bad JSON
},
}
if errInfo != nil {
op.historyRecord.LastErrorTime = fftypes.Now()
op.historyRecord.LastErrorTime = actionOccurred
}
p.writer.queue(ctx, op)
return nil // completely async
Expand Down
Loading

0 comments on commit 0b9557f

Please sign in to comment.