Skip to content

Commit

Permalink
Merge pull request #81 from kaleido-io/tx-event
Browse files Browse the repository at this point in the history
Fill in event fields from transactions that do not publish events
  • Loading branch information
peterbroadhurst authored Mar 11, 2022
2 parents ee1ad31 + ec5357d commit f54ba80
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/fabric/utils/blockdecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@ func GetEvents(block *common.Block) []*api.EventEntry {
}
for idx, entry := range rawBlock.Data.Data {
timestamp := entry.Payload.Header.ChannelHeader.Timestamp
txId := entry.Payload.Header.ChannelHeader.TxId
actions := entry.Payload.Data.Actions
for actionIdx, action := range actions {
event := action.Payload.Action.ProposalResponsePayload.Extension.Events
if event == nil {
continue
}
// if the transaction did not publish any events, we need to get most of the
// information below from other parts of the transaction
chaincodeId := action.Payload.Action.ProposalResponsePayload.Extension.ChaincodeId.Name
eventEntry := api.EventEntry{
ChaincodeId: event.ChaincodeId,
ChaincodeId: chaincodeId,
BlockNumber: rawBlock.Header.Number,
TransactionId: event.TxId,
TransactionId: txId,
TransactionIndex: idx,
EventIndex: actionIdx, // each action only allowed one event, so event index is the action index
EventName: event.EventName,
Expand Down

0 comments on commit f54ba80

Please sign in to comment.