Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method ethClient.SubscribeFilterLogs got event log twice #1867

Closed
van-bright opened this issue Sep 17, 2021 · 2 comments
Closed

method ethClient.SubscribeFilterLogs got event log twice #1867

van-bright opened this issue Sep 17, 2021 · 2 comments
Assignees
Labels
bug 🐛 Something isn't working

Comments

@van-bright
Copy link
Contributor

System information

PlatON version: platon version 1.1.0
OS & Version:Linux
Commit hash : (if develop)

Expected behaviour

When target event filtered, there should be noticed only once

Actual behaviour

got noticed twice

Steps to reproduce the behaviour

  1. write some code like below to subscribe event for contract:
package main

import (
    "context"
    "fmt"
    "log"
    "strings"
    "math/big"

    "github.com/PlatONnetwork/PlatON-Go/crypto"
    "github.com/PlatONnetwork/PlatON-Go"
    "github.com/PlatONnetwork/PlatON-Go/common"
    "github.com/PlatONnetwork/PlatON-Go/accounts/abi"
    "github.com/PlatONnetwork/PlatON-Go/core/types"
    "github.com/PlatONnetwork/PlatON-Go/ethclient"
)

func main() {
    client, err := ethclient.Dial("wss://devnetopenapi.platon.network/ws")
    if err != nil {
        log.Fatal(err)
    }

    contractAddress := common.MustBech32ToAddress("lat1xt80enwhxtj2tspr48cv8q9t2sp6shx6klfvmf")
    query := platon.FilterQuery{
        Addresses: []common.Address{contractAddress},
    }

    logs := make(chan types.Log)
    sub, err := client.SubscribeFilterLogs(context.Background(), query, logs)
    if err != nil {
        log.Fatal(err)
    }

    for {
        select {
        case err := <-sub.Err():
            log.Fatal(err)
        case vLog := <-logs:
            fmt.Println(vLog) //  got noticed twice
        }
    }
}
  1. trigger some events in the contract
  2. got vLog noticed twice.
@benbaley
Copy link
Member

fixed in #1868

@benbaley
Copy link
Member

close by done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants