Commit Graph

6 Commits

Author SHA1 Message Date
Henry de Valence 0a85be285d Add addr, getaddr serialization. 2019-09-27 20:41:45 -04:00
Henry de Valence ab06750db3 zebra-network: move types -> protocol::types
These types are used for protocol messages, so it makes more sense to
keep them scoped with the protocol handling, rather than other
networking logic.
2019-09-27 20:41:45 -04:00
Henry de Valence f45bbeba98
Replace `Version` `MetaAddr` with `(Services, SocketAddr)`. (#12)
* Replace Version MetaAddr by (Services, SocketAddr).

The version handshake message doesn't include last-seen timestamps for
the address fields, unlike other messages, so instead of modeling the
message data with a `MetaAddr` (which includes a timestamp), we should
just use a tuple.

* Simplify try_read_version implementation.

Because we no longer need to construct fake timestamps for the
`MetaAddr` fields, we don't need to use any of the parsed fields while
parsing later fields, and we can neatly wrap up the entire parsing logic
into a single expression.

* fmt

I didn't have the toolchain-specified `rustfmt` because I was mostly
offline and couldn't download it.
2019-09-19 09:38:02 -07:00
Henry de Valence 733d090b9b Add missing derives to newtypes. 2019-09-18 17:32:06 -04:00
Henry de Valence 1f280b7bb8 Make MetaAddr fields public. 2019-09-18 17:32:06 -04:00
Henry de Valence b9af047a09 Introduce a `MetaAddr` type replacing `NetworkAddress`.
The `NetworkAddress` type was a `(Services, SocketAddr)` pair as used in the
`version` handshake message, described as the `net_addr` struct in the Bitcoin
wiki protocol documentation.  However, all of the other uses of the `net_addr`
struct are a `(Timestamp, Services, SocketAddr)` pair (where the timestamp is
the last-seen time of the peer), and the timestamp is omitted only during the
`version` messages, which are used only during the handshake, so it seems
better to include the timestamp field and omit it during serialization of
`version` packets.
2019-09-18 17:32:06 -04:00