dparlevliet / node.bittrex.api

Node Bittrex API is an asynchronous node.js library for the Bittrex API, the data can be received either via GET request or Stream.
MIT License
253 stars 100 forks source link

Using listen and subscribe returns duplicate results v0.8.1 #74

Closed webworker01 closed 6 years ago

webworker01 commented 6 years ago

It seems we must now use listen as well as subscribe if we want to get updateSummaryState and updateExchangeState results.

However doing this now returns updateSummaryState and updateExchangeState in both callbacks resulting in duplicate data.

BenedictKing commented 6 years ago

You have to use subscribe for updateExchangeState and listen for updateSummaryState separately.

webworker01 commented 6 years ago

Yes thank you, that's what I've done.

I receive results for both in both callbacks instead of the expected behavior of listen returning just updateSummaryState results and subscribe returning just updateExchangeState results.

BenedictKing commented 6 years ago

If you have check the source code you would know why.

data.M.forEach(function(M) {
  if (websocketGlobalTickerCallback) {
    websocketGlobalTickerCallback(M, wsclient);
  }
  if (websocketMarketsCallback) {
    websocketMarketsCallback(M, wsclient);
  }
});
dparlevliet commented 6 years ago

Yes, I knew this would happen when I did it. I only kept it that way because all of the examples from the original versions showed that you needed to filter for the data type. I considered changing it but thought a smaller change would be better than I'll wait to see how people felt about it. I, for one, want to change it. Cast your vote, let me know if it'd screw up anything you've done.

webworker01 commented 6 years ago

Sorry if I am not describing what is happening as clearly as I hoped.

image

In this image you can see that I'm making both connections, I am now using subscribe(), and then separately listen(). In the callbacks for each I still have the filters in place checking data.M for the types of data being returned.

I believe that now it is returning duplicate results to both callbacks as if I used subscribe twice and listen twice. My database has grown to twice the size in a few days (I prune results every 24 hours) and I'm seeing duplicate records.

dparlevliet commented 6 years ago

Hm, ok that's not what I thought you were describing. That is odd.

webworker01 commented 6 years ago

It's odd, seems to not be doing this anymore. Gonna close the issue.

dparlevliet commented 6 years ago

It seems consistent with the issues I've been experiencing on the website. I've been getting repeat entries in the order history showing up on their website so it was likely a fixed bug.

webworker01 commented 6 years ago

Thank you, I thought I was going mad :)