-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(baseapp): integrate the appdata.Listener
in baseapp
#21965
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe changes in this pull request enhance the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
@cool-develope your pull request is missing a changelog! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (1)
baseapp/streaming.go (1)
175-176
: Set appropriateBlockStage
for events.Currently,
BlockStage
is set toappdata.UnknownBlockStage
. If you know the specific block stage during which these events occur, consider setting it to the appropriate constant to improve event classification.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (1)
- baseapp/streaming.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
baseapp/streaming.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
if err := p.listener.StartBlock(appdata.StartBlockData{ | ||
Height: uint64(req.Height), | ||
HeaderBytes: nil, // TODO: need to define a header struct including enc/decoding | ||
HeaderJSON: nil, // TODO: need to define a header json struct | ||
}); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address TODOs for HeaderBytes
and HeaderJSON
in StartBlockData
.
The HeaderBytes
and HeaderJSON
fields are currently set to nil
, with TODO comments indicating the need to define a header struct including encoding and decoding. Implementing these fields is important for proper handling of header information in the listener.
Would you like assistance in defining the header struct and implementing the necessary encoding/decoding functions?
if p.listener.OnTx != nil { | ||
for i, tx := range req.Txs { | ||
if err := p.listener.OnTx(appdata.TxData{ | ||
TxIndex: int32(i), | ||
Bytes: func() ([]byte, error) { return tx, nil }, | ||
JSON: nil, // TODO: need to define a tx json struct | ||
}); err != nil { | ||
return err | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement JSON representation for transactions in TxData
.
In the OnTx
listener invocation, the JSON
field of TxData
is set to nil
, with a TODO comment indicating the need to define a JSON struct for transactions. Providing a JSON representation of transactions may be important for downstream processing or indexing.
Do you need help in defining the transaction JSON struct and implementing its encoding?
if p.listener.OnEvent != nil { | ||
events := make([]appdata.Event, len(res.Events)) | ||
for i, event := range res.Events { | ||
events[i] = appdata.Event{ | ||
BlockStage: appdata.UnknownBlockStage, | ||
Type: event.Type, | ||
Data: nil, | ||
Attributes: func() ([]appdata.EventAttribute, error) { | ||
attrs := make([]appdata.EventAttribute, len(event.Attributes)) | ||
for j, attr := range event.Attributes { | ||
attrs[j] = appdata.EventAttribute{ | ||
Key: attr.Key, | ||
Value: attr.Value, | ||
} | ||
} | ||
return attrs, nil | ||
}, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Events are constructed but not processed; missing call to OnEvent
method.
After constructing the events
slice from res.Events
, the code does not invoke any method to process these events. This may result in events not being properly handled by the listener.
You may need to call p.listener.OnEvent
with the constructed events
slice to ensure events are processed correctly. For example:
if err := p.listener.OnEvent(events); err != nil {
return err
}
Description
Closes: #21526
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Bug Fixes