NebulousLabs/Sia — pull request #99 by lukechampine (2014-05-04 07:13:09+00:00)
Title: RPC and Sectors

This really should be two PRs but oh well.

The major changes here are a result of creating `data.go`, which the `Segment`, `Sector`, and `Ring` types outlined in #67. The implementations of `EncodeRing()` and `RebuildSector()` now more closely match their names; `EncodeRing()` takes a `Sector` and returns a `Ring`, and `RebuildSector()` takes a slice of `Segment`s and returns a `Sector.

The other half of this PR relates to exploring RPC as a means of network communication. The [rpc package](golang.org/pkg/net/rpc/) allows servers to make methods available across a network. This makes functions like `downloadFile()` much more concise and maintainable. As an added bonus, rpc automatically encodes its data using gob, so no extra marshalling is needed.

For now, RPC has been implemented alongside TCP instead of replacing it. If it is deemed feasible, all current TCP communication will be phased out in favor of RPC.

One last change: erasure-coding now uses `[]byte`s exclusively, instead of converting back and forth between strings. This should make encoding/decoding slightly more efficient.