use single pointer instead

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-09-09 19:57:07 +08:00
parent cf7252e2bc
commit ba67bef6a7
2 changed files with 3 additions and 5 deletions

View file

@ -564,8 +564,7 @@ func notifyLogsIf(notifier notifier, id rpc.ID, logs []*types.Log, hashes *lru.B
hashes.Add(batch.hash, struct{}{}) hashes.Add(batch.hash, struct{}{})
} }
for _, log := range logs[batch.start:batch.end] { for _, log := range logs[batch.start:batch.end] {
log := log notifier.Notify(id, log)
notifier.Notify(id, &log)
} }
} }
} }

View file

@ -880,7 +880,7 @@ func TestLogsSubscription(t *testing.T) {
for { for {
select { select {
case log := <-tt.notifier.c: case log := <-tt.notifier.c:
fetched = append(fetched, *log.(**types.Log)) fetched = append(fetched, log.(*types.Log))
case <-timeout: case <-timeout:
break fetchLoop break fetchLoop
} }
@ -941,7 +941,6 @@ func parseTransferLog(log *types.Log) (from, to common.Address, amount uint64) {
func calculateBalance(logs []*types.Log) map[common.Address]uint64 { func calculateBalance(logs []*types.Log) map[common.Address]uint64 {
balances := make(map[common.Address]uint64) balances := make(map[common.Address]uint64)
for _, log := range logs { for _, log := range logs {
log := log
from, to, amount := parseTransferLog(log) from, to, amount := parseTransferLog(log)
if _, ok := balances[from]; !ok { if _, ok := balances[from]; !ok {
@ -1042,7 +1041,7 @@ func testLogsSubscriptionReorg(t *testing.T, oldChainMaker, newChainMaker, pendi
for { for {
select { select {
case log := <-notifier.c: case log := <-notifier.c:
l := *log.(**types.Log) l := log.(*types.Log)
fetched = append(fetched, l) fetched = append(fetched, l)
// We halt the sender by blocking Notify(). However sender will already prepare // We halt the sender by blocking Notify(). However sender will already prepare