mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
accounts/abi/bind/v2: simplify EventIterator.Next interface: don't return error
This commit is contained in:
parent
24dbfc82cd
commit
829c3cba34
2 changed files with 11 additions and 19 deletions
|
|
@ -106,10 +106,10 @@ func (it *EventIterator[T]) Value() *T {
|
|||
// If the attempt to convert the raw log object to an instance of T using the
|
||||
// unpack function provided via FilterEvents returns an error: that error is
|
||||
// returned and subsequent calls to Next will not advance the iterator.
|
||||
func (it *EventIterator[T]) Next() (advanced bool, err error) {
|
||||
func (it *EventIterator[T]) Next() (advanced bool) {
|
||||
// If the iterator failed with an error, don't proceed
|
||||
if it.fail != nil || it.closed {
|
||||
return false, it.fail
|
||||
return false
|
||||
}
|
||||
// if the iterator is still active, block until a log is received or the
|
||||
// underlying subscription terminates.
|
||||
|
|
@ -118,10 +118,10 @@ func (it *EventIterator[T]) Next() (advanced bool, err error) {
|
|||
res, err := it.unpack(&log)
|
||||
if err != nil {
|
||||
it.fail = err
|
||||
return false, it.fail
|
||||
return false
|
||||
}
|
||||
it.current = res
|
||||
return true, it.fail
|
||||
return true
|
||||
case <-it.sub.Err():
|
||||
// regardless of how the subscription ends, still be able to iterate
|
||||
// over any unread logs.
|
||||
|
|
@ -130,12 +130,12 @@ func (it *EventIterator[T]) Next() (advanced bool, err error) {
|
|||
res, err := it.unpack(&log)
|
||||
if err != nil {
|
||||
it.fail = err
|
||||
return false, it.fail
|
||||
return false
|
||||
}
|
||||
it.current = res
|
||||
return true, it.fail
|
||||
return true
|
||||
default:
|
||||
return false, it.fail
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,24 +286,16 @@ done:
|
|||
|
||||
e1Count = 0
|
||||
e2Count = 0
|
||||
for {
|
||||
advanced, err := it.Next()
|
||||
if err != nil {
|
||||
for it.Next() {
|
||||
if err := it.Error(); err != nil {
|
||||
t.Fatalf("got error while iterating events for e1: %v", err)
|
||||
}
|
||||
if !advanced {
|
||||
break
|
||||
}
|
||||
e1Count++
|
||||
}
|
||||
for {
|
||||
advanced, err := it2.Next()
|
||||
if err != nil {
|
||||
for it2.Next() {
|
||||
if err := it2.Error(); err != nil {
|
||||
t.Fatalf("got error while iterating events for e2: %v", err)
|
||||
}
|
||||
if !advanced {
|
||||
break
|
||||
}
|
||||
e2Count++
|
||||
}
|
||||
if e1Count != 2 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue