-
Notifications
You must be signed in to change notification settings - Fork 38
[GH-75] Sending/Receiving Blocks #102
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
Conversation
| end) | ||
|
|
||
| ## Block was validated, now we can send it to other peers | ||
| serialized_block = Serialization.block(b, :serialize) |
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 serialization should not bein the chain
| end | ||
|
|
||
| ## Internal functions | ||
| defp send_to_peers(:post, uri, data, []) do |
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.
there sould be no special case, for peer <- peers do should work with empty list. You can log to debug after sending to how many peers it was sent
| true -> Logger.info(" This transaction has already been added") | ||
| false -> Peers.broadcast_tx(tx) | ||
| true -> Logger.info(" This transaction already has been added") | ||
| false -> Peers.async_request({:new_tx, Serialization.tx(tx, :serialize)}) |
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.
do the serialization by case in async_request
| @doc """ | ||
| Every async requests to the peers will be send from here | ||
| """ | ||
| @spec async_request({type :: atom(), data :: term()}) :: :ok | :error |
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 should have a more semantic correct name, like broadcast_all_peers
| defp send_to_peers(:post, uri, data, []) do | ||
| Logger.warn("Empty peers list") | ||
| end | ||
| defp send_to_peers(:post, uri, data, peers) do |
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.
sending will always happen with :post, no need to specify. What is uri needed for, each peer should have its own uri
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.
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 have to look at it in more detail, thanks
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.
Can you rename it to something else? In the peers worker, uri is always used as the address of the peer, this is why I was so confused
|
can you resolve the compiler warnings, as well? |
|
When having two nodes, mining on the first one, suspending and then continue mining on the second node |
General description
closes #75