From 4b58a254c57cde70aa9a9b5a19e78e0f97c875e3 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Fri, 8 Jan 2021 23:21:55 +0000 Subject: [PATCH 1/2] encode: add some more generic impls (more tuples, references) --- src/consensus/encode.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/consensus/encode.rs b/src/consensus/encode.rs index 20ca31ec12..d422cd6587 100644 --- a/src/consensus/encode.rs +++ b/src/consensus/encode.rs @@ -679,6 +679,31 @@ impl Decodable for CheckedData { } } +// References +impl<'a, T: Encodable> Encodable for &'a T { + fn consensus_encode(&self, s: S) -> Result { + (&**self).consensus_encode(s) + } +} + +impl<'a, T: Encodable> Encodable for &'a mut T { + fn consensus_encode(&self, s: S) -> Result { + (&**self).consensus_encode(s) + } +} + +impl Encodable for ::std::rc::Rc { + fn consensus_encode(&self, s: S) -> Result { + (&**self).consensus_encode(s) + } +} + +impl Encodable for ::std::sync::Arc { + fn consensus_encode(&self, s: S) -> Result { + (&**self).consensus_encode(s) + } +} + // Tuples macro_rules! tuple_encode { ($($x:ident),*) => ( @@ -707,8 +732,11 @@ macro_rules! tuple_encode { } tuple_encode!(T0, T1); +tuple_encode!(T0, T1, T2); tuple_encode!(T0, T1, T2, T3); +tuple_encode!(T0, T1, T2, T3, T4); tuple_encode!(T0, T1, T2, T3, T4, T5); +tuple_encode!(T0, T1, T2, T3, T4, T5, T6); tuple_encode!(T0, T1, T2, T3, T4, T5, T6, T7); impl Encodable for sha256d::Hash { From ef116ffbedb65dbf4cdcfd79b45a93c6ffb84cc6 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sat, 9 Jan 2021 16:43:18 +0000 Subject: [PATCH 2/2] Add byteorder pinning for 1.29.0 compatibility They broke their MSRV in a minor release. Co-authored-by: Sebastian Geisler --- README.md | 5 +++++ contrib/test.sh | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 56a1228205..8b2aecad54 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,11 @@ cargo update --package "serde" --precise "1.0.98" cargo update --package "serde_derive" --precise "1.0.98" ``` +For the feature `base64` to work with 1.29.0 we also need to pin `byteorder`: +``` +cargo update -p byteorder --precise "1.3.4" +``` + ## Installing Rust Rust can be installed using your package manager of choice or [rustup.rs](https://rustup.rs). The former way is considered more secure since diff --git a/contrib/test.sh b/contrib/test.sh index b4bf59dd4d..55f43f6b93 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -2,12 +2,17 @@ FEATURES="base64 bitcoinconsensus use-serde rand" -# Pin `cc` for Rust 1.29 -if [ -n "$PIN_VERSIONS" ]; then +pin_common_verions() { cargo generate-lockfile --verbose cargo update -p cc --precise "1.0.41" --verbose cargo update -p serde --precise "1.0.98" --verbose cargo update -p serde_derive --precise "1.0.98" --verbose +} + +# Pin `cc` for Rust 1.29 +if [ -n "$PIN_VERSIONS" ]; then + pin_common_verions + cargo update -p byteorder --precise "1.3.4" fi if [ "$DO_COV" = true ] @@ -58,10 +63,7 @@ then # Pin `cc` for Rust 1.29 if [ -n "$PIN_VERSIONS" ]; then - cargo generate-lockfile --verbose - cargo update -p cc --precise "1.0.41" --verbose - cargo update -p serde --precise "1.0.98" --verbose - cargo update -p serde_derive --precise "1.0.98" --verbose + pin_common_verions fi cargo test --verbose