Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Use Websocket to get new transactions - Closes #843 #889

Merged
merged 13 commits into from
Nov 3, 2017

Conversation

ginacontrino
Copy link
Contributor

@ginacontrino ginacontrino commented Oct 19, 2017

What's the problem?
We were making a request to the server every 10 seconds to update the account/transactions
#843

What did you do?
Removing the metronome to instead use the socket. This way we want to only update the account/transactions when there was a relevant block added.

@ginacontrino ginacontrino force-pushed the 843-websocket branch 2 times, most recently from 8645d8d to 94e18e6 Compare October 20, 2017 13:43
@ginacontrino ginacontrino force-pushed the 843-websocket branch 2 times, most recently from 31284a7 to 9bd856b Compare October 26, 2017 16:13
@ginacontrino ginacontrino force-pushed the 843-websocket branch 2 times, most recently from 01ecc6f to 15fbafa Compare November 2, 2017 09:59
const state = store.getState();
const { peers, account } = state;

if (action.data.windowIsFocused && hasRecentTransactions(state)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For the sake of brevity, pass transactions to this function. the you can do

const { peers, account, transactions } = store.getState();

const ssl = store.getState().peers.data.options.ssl;
const protocol = ssl ? 'https' : 'http';

connection = io.connect(`${protocol}://${store.getState().peers.data.currentPeer}:${store.getState().peers.data.port}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this to a separated function

const socketSetup = (store) => {
let windowIsFocused = true;
const { ipc } = window;
if (ipc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this to a separated function

Copy link
Contributor

@reyraa reyraa left a comment

Choose a reason for hiding this comment

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

Thank you @ginacontrino Good job!

@ginacontrino ginacontrino merged commit 0a7345d into 1.3.0 Nov 3, 2017
@ginacontrino ginacontrino deleted the 843-websocket branch November 3, 2017 09:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants