Skip to content
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

fix: broadcast in-memory blocks #809

Merged
merged 3 commits into from
Aug 1, 2022
Merged

fix: broadcast in-memory blocks #809

merged 3 commits into from
Aug 1, 2022

Conversation

sborrazas
Copy link
Contributor

@sborrazas sborrazas commented Jul 27, 2022

This state check will avoid sending the same mb/kb multiple times, which happens when re-syncing in-memory gens.

refs #808

@sborrazas sborrazas requested review from thepiwo and jyeshe July 27, 2022 22:17
@sborrazas sborrazas self-assigned this Jul 27, 2022
defp push_hash(%__MODULE__{dispatched_hashes: dispatched_hashes}, type_hash) do
queue = :queue.in(type_hash, dispatched_hashes)

if length(:queue.to_list(queue)) > @max_hashes_size do
Copy link
Member

@jyeshe jyeshe Jul 29, 2022

Choose a reason for hiding this comment

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

Could you increase this number please? The counting I am doing is 10 generations (max of sync Server), 20 microblocks and more than 50 transactions each.

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe use some kind of TTL to remove the older ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to ETS for the TTL expiring. thanks!

@sborrazas sborrazas requested a review from jyeshe July 29, 2022 22:12
@subs_target_channels :subs_target_channels

@spec start_link(any()) :: GenServer.on_start()
def start_link(_arg), do: GenServer.start_link(__MODULE__, :ok, name: __MODULE__)

@impl GenServer
def init(:ok) do
{:ok, @no_state}
EtsCache.new(@hashes_table, @expiration_minutes)
Copy link
Member

Choose a reason for hiding this comment

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

One last thing, I would move the creation of this named ETS to outside the GenServer init in case it restarts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@sborrazas sborrazas requested a review from jyeshe July 30, 2022 13:53
@sborrazas sborrazas merged commit 22bfcf6 into master Aug 1, 2022
@sborrazas sborrazas deleted the broadcast-mem branch August 1, 2022 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants