Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fetch certifiers only when needed #3978

Merged
merged 6 commits into from
Dec 27, 2016
Merged

Fetch certifiers only when needed #3978

merged 6 commits into from
Dec 27, 2016

Conversation

ngotchac
Copy link
Contributor

Don't fetch certifiers one every new page navigation (eg. switching from accounts to address book triggers a fetch for every certifiers, which on Ropsten outputs warnings logs for inexisting ones).
Fetch them once, and then fetch when needed based on Event Logs.

@ngotchac ngotchac added A0-pleasereview 🤓 Pull request needs code review. M7-ui labels Dec 27, 2016
logs = contract.parseEventLogs(logs);
logs.forEach((log) => {
const certifier = certifiers.find((c) => c.address === log.address);
if (!certifier) {
console.warn(certifiers, log);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add at least which function it comes from (although it is implicit)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a debug I forgot to remove...

const Confirmed = contract.events.find((e) => e.name === 'Confirmed');
const Revoked = contract.events.find((e) => e.name === 'Revoked');

return (store) => {
const onLogs = (logs) => {
let certifiers = [];
let accounts = []; // these are addresses
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we rather name it "addresses" instead of the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we could (was like this already in the code)

return this._registry
.getContract('badgereg')
return this
.getContract()
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 Definitely prefer this approach & consistency.

@jacogr jacogr added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Dec 27, 2016
@gavofyork gavofyork merged commit 7581ac6 into master Dec 27, 2016
@gavofyork gavofyork deleted the ng-fix-certifiers branch December 27, 2016 15:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants