-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,15 +149,45 @@ type listenerWrapper struct { | |
|
||
func (p listenerWrapper) ListenFinalizeBlock(_ context.Context, req abci.FinalizeBlockRequest, res abci.FinalizeBlockResponse) error { | ||
if p.listener.StartBlock != nil { | ||
err := p.listener.StartBlock(appdata.StartBlockData{ | ||
Height: uint64(req.Height), | ||
}) | ||
if err != nil { | ||
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 { | ||
return err | ||
} | ||
} | ||
|
||
//// TODO txs, events | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Implement JSON representation for transactions in In the 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 commentThe reason will be displayed to describe this comment to others. Learn more. Events are constructed but not processed; missing call to After constructing the You may need to call if err := p.listener.OnEvent(events); err != nil {
return err
} |
||
|
||
return 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
andHeaderJSON
inStartBlockData
.The
HeaderBytes
andHeaderJSON
fields are currently set tonil
, 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?