use legacy events field names

This commit is contained in:
William Banfield
2022-03-04 16:28:38 -05:00
parent ab9963acb3
commit 8fe4aaad96
22 changed files with 267 additions and 269 deletions
+3 -3
View File
@@ -82,7 +82,7 @@ func (b *EventBus) Publish(ctx context.Context, eventValue string, eventData typ
}
func (b *EventBus) PublishEventNewBlock(ctx context.Context, data types.EventDataNewBlock) error {
events := data.ResultFinalizeBlock.BlockEvents
events := data.ResultFinalizeBlock.Events
// add Tendermint-reserved new block event
events = append(events, types.EventNewBlock)
@@ -93,7 +93,7 @@ func (b *EventBus) PublishEventNewBlock(ctx context.Context, data types.EventDat
func (b *EventBus) PublishEventNewBlockHeader(ctx context.Context, data types.EventDataNewBlockHeader) error {
// no explicit deadline for publishing events
events := data.ResultFinalizeBlock.BlockEvents
events := data.ResultFinalizeBlock.Events
// add Tendermint-reserved new block header event
events = append(events, types.EventNewBlockHeader)
@@ -125,7 +125,7 @@ func (b *EventBus) PublishEventStateSyncStatus(ctx context.Context, data types.E
// predefined keys (EventTypeKey, TxHashKey). Existing events with the same keys
// will be overwritten.
func (b *EventBus) PublishEventTx(ctx context.Context, data types.EventDataTx) error {
events := data.Result.TxEvents
events := data.Result.Events
// add Tendermint-reserved events
events = append(events, types.EventTx)
+4 -4
View File
@@ -29,7 +29,7 @@ func TestEventBusPublishEventTx(t *testing.T) {
tx := types.Tx("foo")
result := abci.ExecTxResult{
Data: []byte("bar"),
TxEvents: []abci.Event{
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{{Key: "baz", Value: "1"}}},
},
}
@@ -84,7 +84,7 @@ func TestEventBusPublishEventNewBlock(t *testing.T) {
require.NoError(t, err)
blockID := types.BlockID{Hash: block.Hash(), PartSetHeader: bps.Header()}
resultFinalizeBlock := abci.ResponseFinalizeBlock{
BlockEvents: []abci.Event{
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{
{Key: "baz", Value: "1"},
{Key: "foz", Value: "2"},
@@ -136,7 +136,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
tx := types.Tx("foo")
result := abci.ExecTxResult{
Data: []byte("bar"),
TxEvents: []abci.Event{
Events: []abci.Event{
{
Type: "transfer",
Attributes: []abci.EventAttribute{
@@ -253,7 +253,7 @@ func TestEventBusPublishEventNewBlockHeader(t *testing.T) {
block := types.MakeBlock(0, []types.Tx{}, nil, []types.Evidence{})
resultFinalizeBlock := abci.ResponseFinalizeBlock{
BlockEvents: []abci.Event{
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{
{Key: "baz", Value: "1"},
{Key: "foz", Value: "2"},
+1 -1
View File
@@ -214,7 +214,7 @@ func (env *Environment) BlockResults(ctx context.Context, heightPtr *int64) (*co
Height: height,
TxsResults: results.FinalizeBlock.TxResults,
TotalGasUsed: totalGasUsed,
FinalizeBlockEvents: results.FinalizeBlock.BlockEvents,
FinalizeBlockEvents: results.FinalizeBlock.Events,
ValidatorUpdates: results.FinalizeBlock.ValidatorUpdates,
ConsensusParamUpdates: results.FinalizeBlock.ConsensusParamUpdates,
}, nil
+1 -1
View File
@@ -101,7 +101,7 @@ func TestBlockResults(t *testing.T) {
Height: 100,
TxsResults: results.FinalizeBlock.TxResults,
TotalGasUsed: 15,
FinalizeBlockEvents: results.FinalizeBlock.BlockEvents,
FinalizeBlockEvents: results.FinalizeBlock.Events,
ValidatorUpdates: results.FinalizeBlock.ValidatorUpdates,
ConsensusParamUpdates: results.FinalizeBlock.ConsensusParamUpdates,
}},
+1 -1
View File
@@ -312,7 +312,7 @@ func (app *testApp) FinalizeBlock(req abci.RequestFinalizeBlock) abci.ResponseFi
AppVersion: 1,
},
},
BlockEvents: []abci.Event{},
Events: []abci.Event{},
TxResults: resTxs,
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ func (idx *BlockerIndexer) Index(bh types.EventDataNewBlockHeader) error {
}
// 2. index FinalizeBlock events
if err := idx.indexEvents(batch, bh.ResultFinalizeBlock.BlockEvents, types.EventTypeFinalizeBlock, height); err != nil {
if err := idx.indexEvents(batch, bh.ResultFinalizeBlock.Events, types.EventTypeFinalizeBlock, height); err != nil {
return fmt.Errorf("failed to index FinalizeBlock events: %w", err)
}
+2 -2
View File
@@ -21,7 +21,7 @@ func TestBlockIndexer(t *testing.T) {
require.NoError(t, indexer.Index(types.EventDataNewBlockHeader{
Header: types.Header{Height: 1},
ResultFinalizeBlock: abci.ResponseFinalizeBlock{
BlockEvents: []abci.Event{
Events: []abci.Event{
{
Type: "finalize_event1",
Attributes: []abci.EventAttribute{
@@ -54,7 +54,7 @@ func TestBlockIndexer(t *testing.T) {
require.NoError(t, indexer.Index(types.EventDataNewBlockHeader{
Header: types.Header{Height: int64(i)},
ResultFinalizeBlock: abci.ResponseFinalizeBlock{
BlockEvents: []abci.Event{
Events: []abci.Event{
{
Type: "finalize_event1",
Attributes: []abci.EventAttribute{
+3 -3
View File
@@ -35,7 +35,7 @@ func TestBlockFuncs(t *testing.T) {
require.NoError(t, indexer.IndexBlockEvents(types.EventDataNewBlockHeader{
Header: types.Header{Height: 1},
ResultFinalizeBlock: abci.ResponseFinalizeBlock{
BlockEvents: []abci.Event{
Events: []abci.Event{
{
Type: "finalize_eventA",
Attributes: []abci.EventAttribute{
@@ -73,7 +73,7 @@ func TestBlockFuncs(t *testing.T) {
require.NoError(t, indexer.IndexBlockEvents(types.EventDataNewBlockHeader{
Header: types.Header{Height: int64(i)},
ResultFinalizeBlock: abci.ResponseFinalizeBlock{
BlockEvents: []abci.Event{
Events: []abci.Event{
{
Type: "finalize_eventA",
Attributes: []abci.EventAttribute{
@@ -342,7 +342,7 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult {
Data: []byte{0},
Code: abci.CodeTypeOK,
Log: "",
TxEvents: events,
Events: events,
},
}
}
+2 -2
View File
@@ -170,7 +170,7 @@ INSERT INTO `+tableBlocks+` (height, chain_id, created_at)
return fmt.Errorf("block meta-events: %w", err)
}
// Insert all the block events. Order is important here,
if err := insertEvents(dbtx, blockID, 0, h.ResultFinalizeBlock.BlockEvents); err != nil {
if err := insertEvents(dbtx, blockID, 0, h.ResultFinalizeBlock.Events); err != nil {
return fmt.Errorf("finalize-block events: %w", err)
}
return nil
@@ -221,7 +221,7 @@ INSERT INTO `+tableTxResults+` (block_id, index, created_at, tx_hash, tx_result)
return fmt.Errorf("indexing transaction meta-events: %w", err)
}
// Index any events packaged with the transaction.
if err := insertEvents(dbtx, blockID, txID, txr.Result.TxEvents); err != nil {
if err := insertEvents(dbtx, blockID, txID, txr.Result.Events); err != nil {
return fmt.Errorf("indexing transaction events: %w", err)
}
return nil
@@ -221,7 +221,7 @@ func newTestBlockHeader() types.EventDataNewBlockHeader {
return types.EventDataNewBlockHeader{
Header: types.Header{Height: 1},
ResultFinalizeBlock: abci.ResponseFinalizeBlock{
BlockEvents: []abci.Event{
Events: []abci.Event{
makeIndexedEvent("finalize_event.proposer", "FCAA001"),
makeIndexedEvent("thingy.whatzit", "O.O"),
makeIndexedEvent("my_event.foo", "100"),
@@ -269,7 +269,7 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult {
Data: []byte{0},
Code: abci.CodeTypeOK,
Log: "",
TxEvents: events,
Events: events,
},
}
}
+1 -1
View File
@@ -97,7 +97,7 @@ func (txi *TxIndex) Index(results []*abci.TxResult) error {
}
func (txi *TxIndex) indexEvents(result *abci.TxResult, hash []byte, store dbm.Batch) error {
for _, event := range result.Result.TxEvents {
for _, event := range result.Result.Events {
// only index events with a non-empty type
if len(event.Type) == 0 {
continue
@@ -47,7 +47,7 @@ func BenchmarkTxSearch(b *testing.B) {
Data: []byte{0},
Code: abci.CodeTypeOK,
Log: "",
TxEvents: events,
Events: events,
},
}
+4 -4
View File
@@ -27,7 +27,7 @@ func TestTxIndex(t *testing.T) {
Tx: tx,
Result: abci.ExecTxResult{
Data: []byte{0},
Code: abci.CodeTypeOK, Log: "", TxEvents: nil,
Code: abci.CodeTypeOK, Log: "", Events: nil,
},
}
hash := tx.Hash()
@@ -50,7 +50,7 @@ func TestTxIndex(t *testing.T) {
Tx: tx2,
Result: abci.ExecTxResult{
Data: []byte{0},
Code: abci.CodeTypeOK, Log: "", TxEvents: nil,
Code: abci.CodeTypeOK, Log: "", Events: nil,
},
}
hash2 := tx2.Hash()
@@ -326,7 +326,7 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult {
Data: []byte{0},
Code: abci.CodeTypeOK,
Log: "",
TxEvents: events,
Events: events,
},
}
}
@@ -350,7 +350,7 @@ func benchmarkTxIndex(txsCount int64, b *testing.B) {
Data: []byte{0},
Code: abci.CodeTypeOK,
Log: "",
TxEvents: []abci.Event{},
Events: []abci.Event{},
},
}
if err := batch.Add(txResult); err != nil {
+4 -4
View File
@@ -111,8 +111,8 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
abciResponses.FinalizeBlock = new(abci.ResponseFinalizeBlock)
abciResponses.FinalizeBlock.TxResults = dtxs
abciResponses.FinalizeBlock.TxResults[0] = &abci.ExecTxResult{Data: []byte("foo"), TxEvents: nil}
abciResponses.FinalizeBlock.TxResults[1] = &abci.ExecTxResult{Data: []byte("bar"), Log: "ok", TxEvents: nil}
abciResponses.FinalizeBlock.TxResults[0] = &abci.ExecTxResult{Data: []byte("foo"), Events: nil}
abciResponses.FinalizeBlock.TxResults[1] = &abci.ExecTxResult{Data: []byte("bar"), Log: "ok", Events: nil}
pbpk, err := encoding.PubKeyToProto(ed25519.GenPrivKey().PubKey())
require.NoError(t, err)
abciResponses.FinalizeBlock.ValidatorUpdates = []abci.ValidatorUpdate{{PubKey: pbpk, Power: 10}}
@@ -156,7 +156,7 @@ func TestABCIResponsesSaveLoad2(t *testing.T) {
{Code: 383},
{
Data: []byte("Gotcha!"),
TxEvents: []abci.Event{
Events: []abci.Event{
{Type: "type1", Attributes: []abci.EventAttribute{{Key: "a", Value: "1"}}},
{Type: "type2", Attributes: []abci.EventAttribute{{Key: "build", Value: "stuff"}}},
},
@@ -164,7 +164,7 @@ func TestABCIResponsesSaveLoad2(t *testing.T) {
},
[]*abci.ExecTxResult{
{Code: 383, Data: nil},
{Code: 0, Data: []byte("Gotcha!"), TxEvents: []abci.Event{
{Code: 0, Data: []byte("Gotcha!"), Events: []abci.Event{
{Type: "type1", Attributes: []abci.EventAttribute{{Key: "a", Value: "1"}}},
{Type: "type2", Attributes: []abci.EventAttribute{{Key: "build", Value: "stuff"}}},
}},