mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 22:01:20 +00:00
validate tags
This commit is contained in:
@ -69,16 +69,32 @@ func execBlockOnProxyApp(txEventPublisher types.TxEventPublisher, proxyAppConn p
|
|||||||
|
|
||||||
// NOTE: if we count we can access the tx from the block instead of
|
// NOTE: if we count we can access the tx from the block instead of
|
||||||
// pulling it from the req
|
// pulling it from the req
|
||||||
event := types.EventDataTx{
|
tx := types.Tx(req.GetDeliverTx().Tx)
|
||||||
|
|
||||||
|
tags := make(map[string]interface{})
|
||||||
|
for _, t := range txResult.Tags {
|
||||||
|
// basic validation
|
||||||
|
if t.Key == "" {
|
||||||
|
logger.Info("Got tag with an empty key (skipping)", "tag", t, "tx", tx)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if t.ValueString != "" {
|
||||||
|
tags[t.Key] = t.ValueString
|
||||||
|
} else {
|
||||||
|
tags[t.Key] = t.ValueInt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
txEventPublisher.PublishEventTx(types.EventDataTx{
|
||||||
Height: block.Height,
|
Height: block.Height,
|
||||||
Tx: types.Tx(req.GetDeliverTx().Tx),
|
Tx: tx,
|
||||||
Data: txResult.Data,
|
Data: txResult.Data,
|
||||||
Code: txResult.Code,
|
Code: txResult.Code,
|
||||||
Log: txResult.Log,
|
Log: txResult.Log,
|
||||||
Tags: txResult.Tags,
|
Tags: tags,
|
||||||
Error: txError,
|
Error: txError,
|
||||||
}
|
})
|
||||||
txEventPublisher.PublishEventTx(event)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proxyAppConn.SetResponseCallback(proxyCb)
|
proxyAppConn.SetResponseCallback(proxyCb)
|
||||||
|
@ -82,16 +82,8 @@ func (b *EventBus) PublishEventVote(vote EventDataVote) error {
|
|||||||
func (b *EventBus) PublishEventTx(tx EventDataTx) error {
|
func (b *EventBus) PublishEventTx(tx EventDataTx) error {
|
||||||
// no explicit deadline for publishing events
|
// no explicit deadline for publishing events
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
tags := make(map[string]interface{})
|
tags := tx.Tags
|
||||||
for _, t := range tx.Tags {
|
// add predefined tags (they should overwrite any existing tags)
|
||||||
// TODO [@melekes]: validate, but where?
|
|
||||||
if t.ValueString != "" {
|
|
||||||
tags[t.Key] = t.ValueString
|
|
||||||
} else {
|
|
||||||
tags[t.Key] = t.ValueInt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// predefined tags should come last
|
|
||||||
tags[EventTypeKey] = EventTx
|
tags[EventTypeKey] = EventTx
|
||||||
tags[TxHashKey] = fmt.Sprintf("%X", tx.Tx.Hash())
|
tags[TxHashKey] = fmt.Sprintf("%X", tx.Tx.Hash())
|
||||||
b.pubsub.PublishWithTags(ctx, TMEventData{tx}, tags)
|
b.pubsub.PublishWithTags(ctx, TMEventData{tx}, tags)
|
||||||
|
@ -110,13 +110,13 @@ type EventDataNewBlockHeader struct {
|
|||||||
|
|
||||||
// All txs fire EventDataTx
|
// All txs fire EventDataTx
|
||||||
type EventDataTx struct {
|
type EventDataTx struct {
|
||||||
Height int `json:"height"`
|
Height int `json:"height"`
|
||||||
Tx Tx `json:"tx"`
|
Tx Tx `json:"tx"`
|
||||||
Data data.Bytes `json:"data"`
|
Data data.Bytes `json:"data"`
|
||||||
Log string `json:"log"`
|
Log string `json:"log"`
|
||||||
Code abci.CodeType `json:"code"`
|
Code abci.CodeType `json:"code"`
|
||||||
Tags []*abci.KVPair `json:"tags"`
|
Tags map[string]interface{} `json:"tags"`
|
||||||
Error string `json:"error"` // this is redundant information for now
|
Error string `json:"error"` // this is redundant information for now
|
||||||
}
|
}
|
||||||
|
|
||||||
type EventDataProposalHeartbeat struct {
|
type EventDataProposalHeartbeat struct {
|
||||||
|
Reference in New Issue
Block a user