Skip to content

Commit a9d182d

Browse files
authored
Merge pull request #143 from stevenroose/msrv-1.29
Set MSRV to 1.29 and fix README & Travis accordingly
2 parents 53bda55 + 1b759cb commit a9d182d

File tree

4 files changed

+54
-27
lines changed

4 files changed

+54
-27
lines changed

.travis.yml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,12 @@ rust:
33
- stable
44
- beta
55
- nightly
6-
- 1.24.0
6+
- 1.29.0
77
env:
88
- BITCOINVERSION=0.18.0
99
- BITCOINVERSION=0.18.1
1010
- BITCOINVERSION=0.19.0.1
1111
- BITCOINVERSION=0.19.1
1212

13-
matrix:
14-
allow_failures:
15-
rust: 1.24.0
16-
1713
script:
18-
- |
19-
if [[ "$TRAVIS_RUST_VERSION" == stable ]]
20-
then
21-
rustup component add rustfmt
22-
cargo fmt --all -- --check
23-
fi
24-
- cargo build --verbose
25-
- cargo test --verbose
26-
- cargo build --verbose --examples
27-
# Integration test
28-
- wget https://bitcoincore.org/bin/bitcoin-core-$BITCOINVERSION/bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz
29-
- tar -xzvf bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz
30-
- export PATH=$PATH:$(pwd)/bitcoin-$BITCOINVERSION/bin
31-
- (cd integration_test && ./run.sh)
32-
14+
- ./contrib/test.sh

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,18 @@ fn main() {
3535
```
3636

3737
See `client/examples/` for more usage examples.
38+
39+
40+
# Minimum Supported Rust Version (MSRV)
41+
This library should always compile with any combination of features on **Rust 1.29**.
42+
43+
Because some dependencies have broken the build in minor/patch releases, to
44+
compile with 1.29.0 you will need to run the following version-pinning command:
45+
```
46+
cargo update --package "cc" --precise "1.0.41"
47+
cargo update --package "cfg-if" --precise "0.1.9"
48+
cargo update --package "unicode-normalization" --precise "0.1.9"
49+
cargo update --package "serde_json" --precise "1.0.39"
50+
cargo update --package "serde" --precise "1.0.98"
51+
cargo update --package "serde_derive" --precise "1.0.98"
52+
```

client/src/client.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use bitcoin::{
2525
Address, Amount, Block, BlockHeader, OutPoint, PrivateKey, PublicKey, Script, Transaction,
2626
};
2727
use log::Level::{Debug, Trace, Warn};
28-
use serde::{Deserialize, Serialize};
2928

3029
use error::*;
3130
use json;
@@ -363,11 +362,15 @@ pub trait RpcApi: Sized {
363362
use Error::UnexpectedStructure as err;
364363

365364
// First, remove both incompatible softfork fields.
366-
let map = raw.as_object_mut().ok_or(err)?;
367-
let bip9_softforks = map.remove("bip9_softforks").ok_or(err)?;
368-
let old_softforks = map.remove("softforks").ok_or(err)?;
369-
// Put back an empty "softforks" field.
370-
map.insert("softforks".into(), serde_json::Map::new().into());
365+
// We need to scope the mutable ref here for v1.29 borrowck.
366+
let (bip9_softforks, old_softforks) = {
367+
let map = raw.as_object_mut().ok_or(err)?;
368+
let bip9_softforks = map.remove("bip9_softforks").ok_or(err)?;
369+
let old_softforks = map.remove("softforks").ok_or(err)?;
370+
// Put back an empty "softforks" field.
371+
map.insert("softforks".into(), serde_json::Map::new().into());
372+
(bip9_softforks, old_softforks)
373+
};
371374
let mut ret: json::GetBlockchainInfoResult = serde_json::from_value(raw)?;
372375

373376
// Then convert both softfork types and add them.
@@ -399,7 +402,7 @@ pub trait RpcApi: Sized {
399402
}
400403
let sf: OldBip9SoftFork = serde_json::from_value(sf.clone())?;
401404
ret.softforks.insert(
402-
id.into(),
405+
id.clone(),
403406
json::Softfork {
404407
type_: json::SoftforkType::Bip9,
405408
bip9: Some(json::Bip9SoftforkInfo {

contrib/test.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
# Pin dependencies for Rust v1.29
3+
if [ "$TRAVIS_RUST_VERSION" = "1.29.0" ]; then
4+
cargo generate-lockfile --verbose
5+
cargo update --verbose --package "cc" --precise "1.0.41"
6+
cargo update --verbose --package "cfg-if" --precise "0.1.9"
7+
cargo update --verbose --package "unicode-normalization" --precise "0.1.9"
8+
cargo update --verbose --package "serde_json" --precise "1.0.39"
9+
cargo update --verbose --package "serde" --precise "1.0.98"
10+
cargo update --verbose --package "serde_derive" --precise "1.0.98"
11+
fi
12+
13+
if [ "$TRAVIS_RUST_VERSION" = "stable" ]; then
14+
rustup component add rustfmt
15+
cargo fmt --all -- --check
16+
fi
17+
18+
cargo build --verbose
19+
cargo test --verbose
20+
cargo build --verbose --examples
21+
22+
# Integration test
23+
wget https://bitcoincore.org/bin/bitcoin-core-$BITCOINVERSION/bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz
24+
tar -xzvf bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz
25+
export PATH=$PATH:$(pwd)/bitcoin-$BITCOINVERSION/bin
26+
(cd integration_test && ./run.sh)
27+

0 commit comments

Comments
 (0)