Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

bittrex snapshot use sequence, https add headers to result #235

Merged

Conversation

evan-coygo
Copy link
Contributor

fixes #220

  • adds headers to https.get result
  • gets sequence for bittrex from headers

Copy link
Member

@bmancini55 bmancini55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to make this change, much appreciated!

One comment below on modifying the http.get to be more semantic. Also if you could modify the bittrex test to signal that L2Snapshot now has sequenceId.

Thanks!

@@ -17,7 +17,10 @@ async function get(uri) {
if (res.statusCode !== 200) {
return reject(new Error(results.toString()));
} else {
return resolve(JSON.parse(results));
const resultsParsed = JSON.parse(results);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking it would be cleaner to have an options argument passed to http.get that signals you want a result object instead of the parsed result. The result object should include a result property with the parsed result and a headers property that includes the response headers. This way we are not taking the hit of a full properties copy and attaching a non-sematntic hidden property to it.

I would also be ok making a second method https.getResult that has the same logic as http.get but returns a result object as described above.

@evan-coygo
Copy link
Contributor Author

alrirght @bmancini55 new changes pushed

@evan-coygo
Copy link
Contributor Author

I also noticed that your build requires prettier, but there isn't any easy way to have prettier fix things automatically so I added a format:fix script. I hope that's alright! I think really it would be best if you had a git hook to run formatting before every commit and push using something like husky, that would prevent poorly formatted code from ever reaching the remote and would help avoid failed builds due to formattitng.

Copy link
Member

@bmancini55 bmancini55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks for the changes!

I also noticed that your build requires prettier, but there isn't any easy way to have prettier fix things automatically so I added a format:fix script.

Perfect, thanks!

Added one nit if you have a minute to fix. Otherwise will merge shortly.

let raw = await https.get(uri);
let { data, response } = await https.getResponse(uri);
let raw = data;
const sequence = +response.headers.sequence;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer Number cast over +

@bmancini55 bmancini55 merged commit 4ff028e into altangent:master Jan 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bittrex: Bittrex Level 2 Snapshot should return the sequence Id
3 participants