Commit Graph

35 Commits

Author SHA1 Message Date
Devrandom 4826d0c6cc no_std support
Based on the original work by Justin Moon.

*MSRV unchanged from 1.29.0.*

When `std` is off, `no-std` must be on, and we use the [`alloc`](https://doc.rust-lang.org/alloc/) and core2 crates. The `alloc` crate requires the user define a global allocator.

* Import from `core` and `alloc` instead of `std`
* `alloc` only used if `no-std` is on
* Create `std` feature
* Create `no-std` feature which adds a core2 dependency to polyfill `std::io` features. This is an experimental feature and should be
used with caution.
* CI runs tests `no-std`
* MSRV for `no-std` is 1.51 or so
2021-07-15 09:04:49 +02:00
Devrandom 95aa3bf153 std -> core 2021-06-11 17:28:04 +02:00
Steven Roose 61918dfe81
Change the signature of consensus_encode to return io::Error's
This is instead of encode::Errors because the encoders should
not be allowed to return errors that don't originate in the writer
they are writing into.

This is a part of the method definition that has been relied upon for a
while already.
2021-01-12 17:39:41 +00:00
Steven Roose 767b14f696
Make Inventory and NetworkMessage enums exhaustive
Both by added an `Unknown` variant.
2020-12-21 12:04:26 +00:00
Elichai Turkel c19b736566
Remove the hex dependency 2020-01-20 18:50:02 +02:00
kiminuo 74285738ce Convert numeric representation of ServiceFlags to bitwise OR of the flag names
The changes affect only tests
2019-12-12 00:11:13 +01:00
Steven Roose 0f4f060e8b
Merge pull request #363 from kiminuo/feature/remove-old-todos
Remove two old TODO comments [nit]
2019-12-11 16:53:20 +00:00
kiminuo 269ddb6f07 Remove some old TODO comments 2019-12-11 08:26:04 +01:00
Steven Roose 83f55b7f1d
Follow Rust std practice for RejectReason enum 2019-12-08 20:58:49 +00:00
Steven Roose 5c84e9671f
Optimize Reject message 2019-12-08 20:58:46 +00:00
Andrew Poelstra 854718219e
Merge pull request #345 from stevenroose/serviceflags
Add ServiceFlags type
2019-12-06 21:31:46 +00:00
Steven Roose 3e1e4f92b7
Merge pull request #337 from TheBlueMatt/2019-10-less-deps
Drop hex and byteorder (non-test) deps (and disable useless lints)
2019-12-06 15:38:58 +00:00
Matt Corallo acb43af981 Drop byteorder dependency
Taking an external dependency just to convert ints to byte arrays
is somewhat of a waste, especially when Rust isn't very aggressive
about doing cross-crate LTO.

Note that the latest LLVM pattern-matches this, and while I haven't
tested it, that should mean this means no loss of optimization.
2019-12-05 10:41:00 -05:00
Steven Roose de18e926c1
Use ServiceFlags type in existing API 2019-12-04 23:28:25 +00:00
Steven Roose 33ba7eaa36
Nit in VersionMessage documentation 2019-11-19 22:58:49 +00:00
Tamas Blummer 1b0e31c233 fixed typo 2019-09-21 13:31:03 +02:00
Tamas Blummer 960e3da75b remove #repr on RejectReason
and typo fix
2019-09-10 20:11:25 +02:00
Tamas Blummer 3266c192b6 add reject message 2019-08-27 13:42:46 +02:00
Dimitris Apostolou 132ca5ea95 Fix typos 2019-01-23 14:17:29 -05:00
Carl Dong 0f42ca69b0 Move relevant names into consensus::encode
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
  consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
  instead
- Move network::serialize::Simple{En,De}coder to
  consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
  should never fail
2018-09-25 21:19:35 +08:00
Carl Dong 7e9d393d03 Remove low-level networking support
- Modify VersionMessage constructor to take in parameters directly that
  would have otherwise been extracted from a Socket (now removed)
2018-09-25 21:13:34 +08:00
Jean Pierre Dudey b2594087db Use the `?` (try) instead of the `try!` macro.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 12:47:31 -04:00
Jean Pierre Dudey 77c185d9ec Fix modules documentation title.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-08 17:38:50 -04:00
Savil Srivastava 933dcaeb82 [code hygiene] remove deprecated rustc-serialize
Addresses #96.

Turns out it was being used for hex encoding/decoding, so replaced that with the `hex` crate.

i chose to import the `decode` method as:
```
use hex::decode as hex_decode
```

so that it is clear to the reader what is being decoded when it is called. "decode" is such a generic sounding function name that it would get confusing otherwise.
2018-07-26 09:49:15 -07:00
Andrew Poelstra 17e27ec09f *** IT COMPILES ON RUSTC NIGHTLY ***
Many unit test failures, but this is progress.
2015-04-10 20:55:59 -05:00
Andrew Poelstra e5a3e84c41 Checkpoint commit (nope, not yet to small commit sizes :))
This is mostly fixing compile errors in `cargo test`. We are down
to 3 in `cargo build` and 14 in `cargo test`, at least for this
round.
2015-04-08 17:23:45 -05:00
Andrew Poelstra 200e0fe8e3 Checkpoint commit
27 files changed, 3944 insertions(+), 3812 deletions(-) :} I've
started doing whitespace changes as well, I want everything to
be 4-space tabs from now on.
2015-04-06 20:51:11 -05:00
Andrew Poelstra 811df8a713 Giant collection of fixes ... we are into lifetime errors now :) 2015-04-05 19:10:37 -05:00
Andrew Poelstra 6db25db975 Bunch of error type changes 2015-03-26 11:52:20 -05:00
Andrew Poelstra 11dbc717c4 Show -> Debug 2015-03-26 10:35:31 -05:00
Andrew Poelstra df065c143b fix attributes for compiler changes 2015-03-26 10:31:19 -05:00
Andrew Poelstra c3377032f8 Many syntax changes for rustc, incomplete 2015-01-18 17:39:51 -06:00
Andrew Poelstra ef11e8273b Destroy socket listener on error rather than trying to reconnect; add #derivings
Reconnecting an existing socket simply was not working; the Rust socket
did not expose any methods for reconnection, so I simply tried calling
connect() again. As near as I can tell, this was a no-op --- which makes
sense because both the sending and receiving threads had their own copy
of the Socket, and it's not clear what the synchronization behaviour
should have been.

Instead if the connection fails, we relay this information to the main
thread, wait for an acknowledgement, then simply destroy the listening
thread. The caller can then simply call `start()` again.
2014-09-10 07:15:48 -05:00
Andrew Poelstra a2ce000b2b Revamp Serializable interface to be similar to Encoder/Encodable
This is a massive simplification, fixes a couple endianness bugs (though
not all of them I don't think), should give a speedup, gets rid of the
`serialize_iter` crap.
2014-08-01 09:01:39 -07:00
Andrew Poelstra c9ad7c0b58 Initial commit, move into Cargo 2014-07-18 06:56:17 -07:00