michaelhly / solana-py

Solana Python SDK

Home Page:https://michaelhly.github.io/solana-py

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ws client duplicate transactions

jxad opened this issue · comments

commented

Im using the websocket client on MagicEden program logs

from solana.rpc.websocket_api import (
   connect, 
   RpcTransactionLogsFilterMentions,
)

async def main():
   async with connect(RPC_WS_ENDOINT) as wsClient:
      await wsClient.logs_subscribe(filter_=RpcTransactionLogsFilterMentions(MagicEden.program_address))
      first_resp = await wsClient.recv()
      me_log_sub_id = first_resp[0].result
      async for _, res in enumerate(wsClient):
         data = res[0]
         print(data.result.value.signature)
      await wsClient.logs_unsubscribe(me_log_sub_id)      

asyncio.run(main())

This generates lots of duplicate responses
txs logs

am I missing something?

You're most likely getting the 1st message when the transaction reached "committed" status, then another when it is "finalized". Try setting: commitment='confirmed' in logs_subscribe()

commented

My bad, I haven't included the Confirmed configuration, and I'm still getting duplicated transactions. As you said, it seems that I'm receiving the transaction when it's confirmed and then finalized.