diff options
author | Determinant <[email protected]> | 2019-06-11 14:25:40 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-06-11 14:25:40 -0400 |
commit | ef377f5d85503451a16d50fbc535a7537a28b57f (patch) | |
tree | a57d9268a0984107ad7b483c942a992df6e6a6ec /src | |
parent | 05ffb2ce9f4a0cbaca05a1d46b040743d661ce25 (diff) |
...
Diffstat (limited to 'src')
-rw-r--r-- | src/netaddr.cpp | 10 | ||||
-rw-r--r-- | src/network.cpp | 4 | ||||
-rw-r--r-- | src/stream.cpp | 9 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/netaddr.cpp b/src/netaddr.cpp index 109a6ac..1387b84 100644 --- a/src/netaddr.cpp +++ b/src/netaddr.cpp @@ -30,6 +30,16 @@ uint32_t netaddr_get_ip(const netaddr_t *self) { return self->ip; } uint16_t netaddr_get_port(const netaddr_t *self) { return self->port; } +netaddr_array_t *netaddr_array_new() { return new netaddr_array_t(); } +netaddr_array_t *netaddr_array_new_from_addrs(const netaddr_t * const *addrs, size_t naddrs) { + auto res = new netaddr_array_t(); + for (size_t i = 0; i < naddrs; i++) + (*res)[i] = *addrs[i]; + return res; +} + +void netaddr_array_free(netaddr_array_t *self) { delete self; } + } #endif diff --git a/src/network.cpp b/src/network.cpp index 673cc24..39eec4c 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -111,8 +111,8 @@ void peernetwork_send_msg(peernetwork_t *self, void peernetwork_multicast_msg(peernetwork_t *self, msg_t *_moved_msg, - const netaddr_t *paddrs, size_t npaddrs) { - self->_multicast_msg(std::move(*_moved_msg), paddrs, npaddrs); + const netaddr_array_t *paddrs) { + self->multicast_msg(std::move(*_moved_msg), *paddrs); delete _moved_msg; } diff --git a/src/stream.cpp b/src/stream.cpp index 3e24292..b14bd6a 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -24,8 +24,8 @@ void uint256_unserialize(uint256_t *self, datastream_t *s) { } datastream_t *datastream_new() { return new datastream_t(); } -datastream_t *datastream_new_from_bytes(const uint8_t *begin, const uint8_t *end) { - return new datastream_t(begin, end); +datastream_t *datastream_new_from_bytes(const uint8_t *base, size_t size) { + return new datastream_t(base, base + size); } void datastream_free(const datastream_t *self) { delete self; } @@ -54,9 +54,8 @@ void datastream_put_i16(datastream_t *self, int16_t val) { *self << val; } void datastream_put_i32(datastream_t *self, int32_t val) { *self << val; } void datastream_put_i64(datastream_t *self, int64_t val) { *self << val; } -void datastream_put_data(datastream_t *self, - const uint8_t *begin, const uint8_t *end) { - self->put_data(begin, end); +void datastream_put_data(datastream_t *self, const uint8_t *base, size_t size) { + self->put_data(base, base + size); } uint8_t datastream_get_u8(datastream_t *self) { uint8_t val; *self >> val; return val; } |