|
@ -50,7 +50,9 @@ func (es *EventSink) IndexBlockEvents(h types.EventDataNewBlockHeader) error { |
|
|
sqlStmt := sq. |
|
|
sqlStmt := sq. |
|
|
Insert(TableEventBlock). |
|
|
Insert(TableEventBlock). |
|
|
Columns("key", "value", "height", "type", "created_at", "chain_id"). |
|
|
Columns("key", "value", "height", "type", "created_at", "chain_id"). |
|
|
PlaceholderFormat(sq.Dollar) |
|
|
|
|
|
|
|
|
PlaceholderFormat(sq.Dollar). |
|
|
|
|
|
Suffix("ON CONFLICT (key,height)"). |
|
|
|
|
|
Suffix("DO NOTHING") |
|
|
|
|
|
|
|
|
ts := time.Now() |
|
|
ts := time.Now() |
|
|
// index the reserved block height index
|
|
|
// index the reserved block height index
|
|
@ -83,12 +85,16 @@ func (es *EventSink) IndexTxEvents(txr []*abci.TxResult) error { |
|
|
Columns("tx_result", "created_at"). |
|
|
Columns("tx_result", "created_at"). |
|
|
PlaceholderFormat(sq.Dollar). |
|
|
PlaceholderFormat(sq.Dollar). |
|
|
RunWith(es.store). |
|
|
RunWith(es.store). |
|
|
|
|
|
Suffix("ON CONFLICT (tx_result)"). |
|
|
|
|
|
Suffix("DO NOTHING"). |
|
|
Suffix("RETURNING \"id\"") |
|
|
Suffix("RETURNING \"id\"") |
|
|
|
|
|
|
|
|
sqlStmtEvents := sq. |
|
|
sqlStmtEvents := sq. |
|
|
Insert(TableEventTx). |
|
|
Insert(TableEventTx). |
|
|
Columns("key", "value", "height", "hash", "tx_result_id", "created_at", "chain_id"). |
|
|
Columns("key", "value", "height", "hash", "tx_result_id", "created_at", "chain_id"). |
|
|
PlaceholderFormat(sq.Dollar) |
|
|
|
|
|
|
|
|
PlaceholderFormat(sq.Dollar). |
|
|
|
|
|
Suffix("ON CONFLICT (key,hash)"). |
|
|
|
|
|
Suffix("DO NOTHING") |
|
|
|
|
|
|
|
|
ts := time.Now() |
|
|
ts := time.Now() |
|
|
for _, tx := range txr { |
|
|
for _, tx := range txr { |
|
@ -100,17 +106,24 @@ func (es *EventSink) IndexTxEvents(txr []*abci.TxResult) error { |
|
|
sqlStmtTxResult = sqlStmtTxResult.Values(txBz, ts) |
|
|
sqlStmtTxResult = sqlStmtTxResult.Values(txBz, ts) |
|
|
|
|
|
|
|
|
// execute sqlStmtTxResult db query and retrieve the txid
|
|
|
// execute sqlStmtTxResult db query and retrieve the txid
|
|
|
err = sqlStmtTxResult.QueryRow().Scan(&txid) |
|
|
|
|
|
|
|
|
r, err := sqlStmtTxResult.Query() |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !r.Next() { |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := r.Scan(&txid); err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// index the reserved height and hash indices
|
|
|
// index the reserved height and hash indices
|
|
|
hash := fmt.Sprintf("%X", types.Tx(tx.Tx).Hash()) |
|
|
hash := fmt.Sprintf("%X", types.Tx(tx.Tx).Hash()) |
|
|
|
|
|
|
|
|
sqlStmtEvents = sqlStmtEvents.Values(types.TxHashKey, hash, tx.Height, hash, txid, ts, es.chainID) |
|
|
sqlStmtEvents = sqlStmtEvents.Values(types.TxHashKey, hash, tx.Height, hash, txid, ts, es.chainID) |
|
|
sqlStmtEvents = sqlStmtEvents.Values(types.TxHeightKey, fmt.Sprint(tx.Height), tx.Height, hash, txid, ts, es.chainID) |
|
|
sqlStmtEvents = sqlStmtEvents.Values(types.TxHeightKey, fmt.Sprint(tx.Height), tx.Height, hash, txid, ts, es.chainID) |
|
|
|
|
|
|
|
|
for _, event := range tx.Result.Events { |
|
|
for _, event := range tx.Result.Events { |
|
|
// only index events with a non-empty type
|
|
|
// only index events with a non-empty type
|
|
|
if len(event.Type) == 0 { |
|
|
if len(event.Type) == 0 { |
|
|