-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
rpc/src/v1/impls/parity.rs
Outdated
@@ -79,7 +79,7 @@ impl<C, M, S: ?Sized, U> ParityClient<C, M, S, U> where | |||
U: UpdateService, | |||
{ | |||
/// Creates new `ParityClient`. | |||
pub fn new( | |||
pub fn new ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. You can also save the promise and then unsubscribe with resolving the promise. Otherwise it can happen that you unsubscribe before even having the subscriptionId, which would be invalid and have to be repeated.
I'm not sure where local transactions are all used but seems fine @jacogr .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple grumbles.
Cargo.lock
Outdated
@@ -418,6 +418,14 @@ dependencies = [ | |||
] | |||
|
|||
[[package]] | |||
name = "error-chain" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like those changes are unnecessary.
} | ||
|
||
stopPolling () { | ||
Object.keys(this._timeoutIds).forEach((key) => clearTimeout(this._timeoutIds[key])); | ||
if (this.subscriptionId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should wait for subscriptionId
, otherwise if you stopPolling
before the promises in startPolling
are resolved you may end up with dangling subscription.
js/src/views/Signer/store.js
Outdated
@@ -49,8 +49,8 @@ export default class SignerStore { | |||
} | |||
|
|||
@action unsubscribe () { | |||
if (this._timeoutId) { | |||
clearTimeout(this._timeoutId); | |||
if (this.subscriptionId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should always wait for subscription id, otherwise you may end up with a dangling subscription.
js/src/views/Signer/store.js
Outdated
@@ -88,20 +88,18 @@ export default class SignerStore { | |||
} | |||
|
|||
fetchLocalTransactions = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name suggests that the transactions will be fetched, but actually it sets up a subscription.
The name should be altered and it should be ensured that the method is never called more than once.
js/src/views/Signer/store.js
Outdated
}) | ||
.then((subscriptionId) => { | ||
this.subscriptionId = subscriptionId; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to at least log errors here.
this.blockNumber = block.number; | ||
this.blockTimestamp = block.timestamp; | ||
this._pollMinerSettings(); | ||
return Promise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
here is misleading, it looks a bit like then(subscriptionId)
is chained to this promise, but it's not.
}) | ||
.then((subscriptionId) => { | ||
this.subscriptionId = subscriptionId; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to at least log errors.
cleaned up and handles all errors/use cases. Lemme know what you think. |
js/src/views/Signer/store.js
Outdated
const self = this; | ||
|
||
if (self.subscribed) { | ||
if (!self.subscriptionId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify the code by saving the promise itself as subscription and then resolving it in unsubscribe.
This works fine when the id does not need to get exposed.
E.g. like here in the bonds library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I understand your design now and how nice that is. Sorry I didn't fully understand your first comment.
@tomusdrw could you take a look at this? |
js/src/api/pubsub/parity/parity.js
Outdated
}); | ||
return transactions; | ||
}); | ||
: callback(null, transactions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we get rid of the outTransaction
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Brought it back.
@ngotchac Fixed, please have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I just think that the NodeStatus/store
should be a singleton, instanciated once. But this was introduced in another PR so...
@kaikun213 -