-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
Changes Unknown when pulling 54e2844 on ng-smarter-contracts into ** on master**. |
@@ -50,10 +51,15 @@ export function inHash (hash) { | |||
return inHex(hash); | |||
} | |||
|
|||
export function pad (input, length) { |
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.
Don't we have this function already? (Seems duplicated)
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.
This pads the topics on the right
@@ -232,51 +233,102 @@ export default class Contract { | |||
return this._subscribe(event, options, callback); | |||
}; | |||
|
|||
event.register = (options = {}, callback) => { |
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.
Ok, not 100% sure I get the difference between event.register
and event.subscribe
- not from an API user POV.
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 register
method actually calls eth_getFilterChanges
every second, which is unnecessary for getting token meta data updates (will be max a change for every block). We could actually call it every minute or so if needed...
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.
Ok, still unsure about how to explain this since it sits on the API interface. Obviously for any filter when pending is not included (toBlock) just calling the new filter on new blocks is more than enough. (Something to probably think about and enhance)
The case here is that we have 2 external APIs now - how does anybody decide what to use, seems we are making the external interface very complex now.
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.
I guess for filters querying pending blocks too it could be useful to query every second (not sure though). True from the API perspective, but didn't want to change the whole behavior.
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.
Agreed. As a dapp developer - what do I use? subscribe
or register
? As it stands the naming is almost interchangeable. We want things simple so people don't need to overthink things, but still allow them to do anything.
So to accomplish this, would have -
- not have yet another external interface event
- only polled for rapid changes when
pending
is thetoBlock
- poll for filter changes on new blocks only when
latest
istoBlock
- when we poll for tokens, specify
latest
... all wrapped in contracts.js
. This way anybody using the API doesn't need to care about times and polling, the API just does the right thing, as asked. (Plus no confusion)
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.
I agree with this. First I wanted to call it manualSubscribe
or something like that. Will fix
this._sendSubscriptionChanges(); | ||
} | ||
|
||
_unsubscribeToChanges = () => { |
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.
unsubscribeFromChanges
? (;
I haven't looked into this in detail, but at |
The transactions ? |
Yes, may be related to |
Changes Unknown when pulling ef2c170 on ng-smarter-contracts into ** on master**. |
toBlock: 'latest' | ||
}, (error, logs) => { | ||
if (error) { | ||
return console.error('balances::attachToNewToken', 'failed to attacht to tokenreg Registered', error.toString(), error.stack); |
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.
s/attacht/attach/
Changes Unknown when pulling 7f36600 on ng-smarter-contracts into ** on master**. |
Failing tests -
|
Changes Unknown when pulling f4f2c5e on ng-smarter-contracts into ** on master**. |
WIP for #3240
It was useless to fetch data for each and every token on every new block.
Tokens data is not editable. Only meta data can be modified, so we just need to check for this specific event on new block only (no need to poll every second). Same for new tokens registered (might not even be that necessary...).
Fixes also an issue where all accounts were being checked for balances, even deleted ones.