Skip to content

Commit

Permalink
Merge pull request #578 from tablelandnetwork/bcalza/fixtableids
Browse files Browse the repository at this point in the history
fixes table ids duplication in receipts
  • Loading branch information
brunocalza authored May 23, 2023
2 parents d24538c + 8ca688c commit 6c9719e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/eventprocessor/eventfeed/impl/eventfeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func (ef *EventFeed) Start(
// sideffects.
toHeight := h.Number.Int64() - int64(ef.config.MinBlockChainDepth)
if toHeight < fromHeight {
ef.log.Warn().
Int64("from_height", fromHeight).
Int64("to_height", toHeight).
Msgf("from_height bigger than to_height")
break
}

Expand Down
1 change: 1 addition & 0 deletions pkg/eventprocessor/impl/executor/impl/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func TestMultiEventTxnBlock(t *testing.T) {
require.Nil(t, res.Error)
require.Nil(t, res.ErrorEventIdx)
require.Equal(t, eventCreateTable.TableId.Int64(), res.TableID.ToBigInt().Int64())
require.Equal(t, []tables.TableID{tables.TableID(*big.NewInt(100))}, res.TableIDs)
}
// Txn 2
{
Expand Down
7 changes: 5 additions & 2 deletions pkg/eventprocessor/impl/executor/impl/txnscope.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (ts *txnScope) executeTxnEvents(
var res eventExecutionResult
var err error

tableIDs := make([]tables.TableID, 0)
tableIDs, tableIDsMap := make([]tables.TableID, 0), make(map[string]struct{})
for idx, event := range evmTxn.Events {
switch event := event.(type) {
case *ethereum.ContractRunSQL:
Expand Down Expand Up @@ -110,7 +110,10 @@ func (ts *txnScope) executeTxnEvents(
}

if res.TableID != nil {
tableIDs = append(tableIDs, *res.TableID)
if _, ok := tableIDsMap[(*res.TableID).String()]; !ok {
tableIDs = append(tableIDs, *res.TableID)
tableIDsMap[(*res.TableID).String()] = struct{}{}
}
}
}

Expand Down

0 comments on commit 6c9719e

Please sign in to comment.