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

RPC errors #184

Merged
merged 4 commits into from
Jan 8, 2015
Merged

RPC errors #184

merged 4 commits into from
Jan 8, 2015

Conversation

lukechampine
Copy link
Member

RPCs now send and receive errors. Registered functions like SendBlocks that return an error will write that error to the connection. If it's a net.Conn function like RetrieveFile, you have to write the error manually. All existing RPCs have been updated to make use of errors. However, there still isn't much logic for processing specific RPC errors, except in CatchUp, which now looks for a specific "more blocks are available" error.

if prevHeight != c.Height() {
go c.CatchUp(c.RandomPeer())
if err == moreBlocksErr {
go c.CatchUp(peer)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm reusing the old peer here, but that might not be best practice. On one hand, if a peer tells you it has more blocks, you probably want to ask that specific peer again. On the other hand, this allows a malicious host to trap you in an infinite CatchUp loop by always returning moreBlocksErr.

Copy link
Member

Choose a reason for hiding this comment

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

this is avoidable by checking yourself to see that the host has actually supplied more blocks.

@DavidVorick
Copy link
Member

Can you add more documentation? Specifically a file somewhere that explains the general philosophies and approaches behind the network package?

@DavidVorick
Copy link
Member

I'll probably make an issue about it.

DavidVorick added a commit that referenced this pull request Jan 8, 2015
@DavidVorick DavidVorick merged commit 37dee18 into master Jan 8, 2015
@lukechampine
Copy link
Member Author

sure. I'm thinking the package should be renamed anyway (sianet?), so I'll lump those two changes together.

@DavidVorick DavidVorick deleted the net branch January 11, 2015 01:01
@lukechampine lukechampine mentioned this pull request Jan 19, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants