Skip to content

Commit

Permalink
Include operations from related transactions to match intent (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzheng authored Apr 7, 2022
1 parent 3497461 commit 5d4a266
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/processor/broadcast_storage_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var _ modules.BroadcastStorageHandler = (*BroadcastStorageHandler)(nil)
// can be sent to other functions (ex: reconciler).
type BroadcastStorageHandler struct {
config *configuration.Configuration
blockStorage *modules.BlockStorage
counterStorage *modules.CounterStorage
coordinator *coordinator.Coordinator
parser *parser.Parser
Expand All @@ -43,12 +44,14 @@ type BroadcastStorageHandler struct {
// NewBroadcastStorageHandler returns a new *BroadcastStorageHandler.
func NewBroadcastStorageHandler(
config *configuration.Configuration,
blockStorage *modules.BlockStorage,
counterStorage *modules.CounterStorage,
coordinator *coordinator.Coordinator,
parser *parser.Parser,
) *BroadcastStorageHandler {
return &BroadcastStorageHandler{
config: config,
blockStorage: blockStorage,
counterStorage: counterStorage,
coordinator: coordinator,
parser: parser,
Expand All @@ -65,7 +68,17 @@ func (h *BroadcastStorageHandler) TransactionConfirmed(
transaction *types.Transaction,
intent []*types.Operation,
) error {
if err := h.parser.ExpectedOperations(intent, transaction.Operations, false, true); err != nil {
_, _, relatedTransactions, err := h.blockStorage.FindRelatedTransactions(ctx, transaction.TransactionIdentifier, dbTx)
if err != nil {
return fmt.Errorf("%w: could not find related transactions", err)
}

observed := transaction.Operations
for _, relatedTransaction := range relatedTransactions {
observed = append(observed, relatedTransaction.Operations...)
}

if err := h.parser.ExpectedOperations(intent, observed, false, true); err != nil {
return fmt.Errorf("%w: confirmed transaction did not match intent", err)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/tester/construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ func InitializeConstruction(

broadcastHandler := processor.NewBroadcastStorageHandler(
config,
blockStorage,
counterStorage,
coordinator,
parser,
Expand Down

0 comments on commit 5d4a266

Please sign in to comment.