validate tags

This commit is contained in:
Anton Kaliaev
2017-11-29 14:23:43 -06:00
parent a52cdbfe43
commit acae38ab9e
3 changed files with 30 additions and 22 deletions
+2 -10
View File
@@ -82,16 +82,8 @@ func (b *EventBus) PublishEventVote(vote EventDataVote) error {
func (b *EventBus) PublishEventTx(tx EventDataTx) error {
// no explicit deadline for publishing events
ctx := context.Background()
tags := make(map[string]interface{})
for _, t := range tx.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 := tx.Tags
// add predefined tags (they should overwrite any existing tags)
tags[EventTypeKey] = EventTx
tags[TxHashKey] = fmt.Sprintf("%X", tx.Tx.Hash())
b.pubsub.PublishWithTags(ctx, TMEventData{tx}, tags)
+7 -7
View File
@@ -110,13 +110,13 @@ type EventDataNewBlockHeader struct {
// All txs fire EventDataTx
type EventDataTx struct {
Height int `json:"height"`
Tx Tx `json:"tx"`
Data data.Bytes `json:"data"`
Log string `json:"log"`
Code abci.CodeType `json:"code"`
Tags []*abci.KVPair `json:"tags"`
Error string `json:"error"` // this is redundant information for now
Height int `json:"height"`
Tx Tx `json:"tx"`
Data data.Bytes `json:"data"`
Log string `json:"log"`
Code abci.CodeType `json:"code"`
Tags map[string]interface{} `json:"tags"`
Error string `json:"error"` // this is redundant information for now
}
type EventDataProposalHeartbeat struct {