accounts/abi/bind: properly unsubscribe after errors

This commit is contained in:
Marius van der Wijden 2019-12-13 14:17:05 +01:00 committed by GitHub
parent f51cf573b5
commit 57f18c19fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -434,6 +434,7 @@ var (
logs, sub, err := _{{$contract.Type}}.contract.FilterLogs(opts, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}Rule{{end}}{{end}})
if err != nil {
sub.Unsubscribe()
return nil, err
}
return &{{$contract.Type}}{{.Normalized.Name}}Iterator{contract: _{{$contract.Type}}.contract, event: "{{.Original.Name}}", logs: logs, sub: sub}, nil
@ -451,6 +452,7 @@ var (
logs, sub, err := _{{$contract.Type}}.contract.WatchLogs(opts, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}Rule{{end}}{{end}})
if err != nil {
sub.Unsubscribe()
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {