Skip to content

Commit

Permalink
let the length of the topics communicate protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandotsmith committed Oct 1, 2023
1 parent 42e2b73 commit d43a91a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions eth/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,18 @@ func (b Block) String() string {
}

type Log struct {
Address Bytes `json:"address"`
Topics [4]Bytes `json:"topics"`
Data Bytes `json:"data"`
Address Bytes `json:"address"`
Topics []Bytes `json:"topics"`
Data Bytes `json:"data"`
}

func (l *Log) UnmarshalRLP(b []byte) {
iter := rlp.Iter(b)
l.Address.Write(iter.Bytes())
for i, t := 0, rlp.Iter(iter.Bytes()); t.HasNext(); i++ {
l.Topics[i].Write(t.Bytes())
topic := make([]byte, 32)
copy(topic, t.Bytes())
l.Topics = append(l.Topics, topic)
}
l.Data.Write(iter.Bytes())
}
Expand Down
2 changes: 1 addition & 1 deletion integrations/erc20/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (i integration) Insert(ctx context.Context, pg e2pg.PG, blocks []eth.Block)
for ridx := range blocks[bidx].Receipts {
for lidx := range blocks[bidx].Receipts[ridx].Logs {
l := blocks[bidx].Receipts[ridx].Logs[lidx]
if !bytes.Equal(l.Topics[0], sig) {
if !bytes.Equal(l.Topics[0], sig) || len(l.Topics) < 3 {
continue
}
signer, err := blocks[bidx].Txs[ridx].Signer()
Expand Down

0 comments on commit d43a91a

Please sign in to comment.