8000 Pinning Agent refactor to `new_epoch` event by klercker · Pull Request #4499 · aeternity/aeternity · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pinning Agent refactor to new_epoch event #4499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 25, 2024
Merged

Conversation

klercker
Copy link
Contributor
@klercker klercker commented Nov 21, 2024

Move pinning agent invocation code from inner consensus callbacks to separate gen_server+worker process.

This PR is supported by Æternity Foundation

@klercker klercker self-assigned this Nov 21, 2024
@klercker klercker changed the title Pinning Agent reactor to new_epochevent Pinning Agent refactor to new_epoch event Nov 21, 2024
Copy link
Member
@hanssv hanssv left a comment

Choose a reason for hiding this comment

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

The gen-server process should be enough to run this, it is even aptly named something_worker. Spawning yet another process is overkill.

@klercker klercker force-pushed the pinning_agent_event_refac branch from 4cea060 to 853f616 Compare November 22, 2024 14:26
@klercker
Copy link
Contributor Author

The gen_server process is actually named ?SERVER as per usual, the sub process is ?MODULE_worker. Again, the state handling becomes a lot cleaner with the spawned process, and that single process is pretty cheap as we all know.

@hanssv
Copy link
Member
hanssv commented Nov 22, 2024

The gen_server process is actually named ?SERVER as per usual, the sub process is ?MODULE_worker. Again, the state handling becomes a lot cleaner with the spawned process, and that single process is pretty cheap as we all know.

Yes, naming looks updated and correct, the drawback of spawning yet another process is that you need to register for events every time, etc. It is much cleaner and not a lot of work to just put that logic directly in the gen_server.

@klercker
Copy link
Contributor Author

As per "advice" from @richcarl and @happi and others I put it in a separate worker process and I like the look of it (and I really don't like the look of gen_server; it's a great pattern/whatever but the code looks like the llamas arse). I think the number of LOC managing event subscription will actually be higher with gen_server but my .erl incompetence might be fooling me here. Since you might or might not want to listen to top_change all the time (when you are not pinning), you need to either match for it somewhere (unpacking #state{} etc) or turn on and off subscription as you go along. But please prove me wrong.

If it's very very important to you @hanssv, I will refac again, but I really do like the current impl and it's not particularly non-standard.

@hanssv
Copy link
Member
hanssv commented Nov 22, 2024

If Richard and Happi with a straight face will claim that this implementation is superior I will consider to change my mind.

@klercker
Copy link
Contributor Author

Not superior perhaps, but valid 😅

Copy link
Member
@hanssv hanssv left a comment

Choose a reason for hiding this comment

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

Looks good, this one is much nicer!

Comment on lines +209 to +210
#{caller_id => aeser_id:create(account, Who)
, nonce => Nonce
Copy link
Member

Choose a reason for hiding this comment

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

Indentation?

Copy link
Member

Choose a reason for hiding this comment

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

Fix: Space after the curly, and comma aligns with curly...

@klercker klercker requested a review from happi November 25, 2024 11:06
@klercker klercker merged commit d96b79f into master Nov 25, 2024
40 checks passed
@klercker klercker deleted the pinning_agent_event_refac branch November 25, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants
0