Skip to content

Commit f30694b

Browse files
authored
Merge pull request #924 from GeneFerneau/alloc
Use alloc for no_std builds
2 parents 8e7b590 + 12461fc commit f30694b

35 files changed

+68
-12
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use util::logger::Logger;
3737
use util::events;
3838
use util::events::EventHandler;
3939

40+
use prelude::*;
4041
use std::collections::{HashMap, hash_map};
4142
use std::sync::RwLock;
4243
use core::ops::Deref;
@@ -143,7 +144,7 @@ where C::Target: chain::Filter,
143144
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))]
144145
pub fn get_and_clear_pending_events(&self) -> Vec<events::Event> {
145146
use util::events::EventsProvider;
146-
let events = std::cell::RefCell::new(Vec::new());
147+
let events = core::cell::RefCell::new(Vec::new());
147148
let event_handler = |event| events.borrow_mut().push(event);
148149
self.process_pending_events(&event_handler);
149150
events.into_inner()

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use util::ser::{Readable, ReadableArgs, MaybeReadable, Writer, Writeable, U48};
5151
use util::byte_utils;
5252
use util::events::Event;
5353

54+
use prelude::*;
5455
use std::collections::{HashMap, HashSet};
5556
use core::{cmp, mem};
5657
use std::io::Error;
@@ -2911,6 +2912,7 @@ mod tests {
29112912
use bitcoin::secp256k1::Secp256k1;
29122913
use std::sync::{Arc, Mutex};
29132914
use chain::keysinterface::InMemorySigner;
2915+
use prelude::*;
29142916

29152917
#[test]
29162918
fn test_prune_preimages() {

lightning/src/chain/keysinterface.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use ln::chan_utils;
3737
use ln::chan_utils::{HTLCOutputInCommitment, make_funding_redeemscript, ChannelPublicKeys, HolderCommitmentTransaction, ChannelTransactionParameters, CommitmentTransaction};
3838
use ln::msgs::UnsignedChannelAnnouncement;
3939

40+
use prelude::*;
4041
use std::collections::HashSet;
4142
use core::sync::atomic::{AtomicUsize, Ordering};
4243
use std::io::Error;

lightning/src/chain/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitor
1818
use chain::keysinterface::Sign;
1919
use chain::transaction::{OutPoint, TransactionData};
2020

21+
use prelude::*;
22+
2123
pub mod chaininterface;
2224
pub mod chainmonitor;
2325
pub mod channelmonitor;

lightning/src/chain/onchaintx.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use util::logger::Logger;
3232
use util::ser::{Readable, ReadableArgs, Writer, Writeable, VecWriter};
3333
use util::byte_utils;
3434

35+
use prelude::*;
3536
use std::collections::HashMap;
3637
use core::cmp;
3738
use core::ops::Deref;

lightning/src/chain/package.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ use util::byte_utils;
3131
use util::logger::Logger;
3232
use util::ser::{Readable, Writer, Writeable};
3333

34-
use std::cmp;
35-
use std::mem;
36-
use std::ops::Deref;
34+
use core::cmp;
35+
use core::mem;
36+
use core::ops::Deref;
3737

3838
const MAX_ALLOC_SIZE: usize = 64*1024;
3939

lightning/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#![cfg_attr(all(any(test, feature = "_test_utils"), feature = "unstable"), feature(test))]
3232
#[cfg(all(any(test, feature = "_test_utils"), feature = "unstable"))] extern crate test;
3333

34+
extern crate alloc;
3435
extern crate bitcoin;
3536
extern crate core;
3637
#[cfg(any(test, feature = "_test_utils"))] extern crate hex;
@@ -41,3 +42,7 @@ pub mod util;
4142
pub mod chain;
4243
pub mod ln;
4344
pub mod routing;
45+
46+
mod prelude {
47+
pub use alloc::{vec, vec::Vec, string::String};
48+
}

lightning/src/ln/chan_utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use bitcoin::secp256k1::{Secp256k1, Signature, Message};
3131
use bitcoin::secp256k1::Error as SecpError;
3232
use bitcoin::secp256k1;
3333

34+
use prelude::*;
3435
use core::cmp;
3536
use ln::chan_utils;
3637
use util::transaction_utils::sort_outputs;
@@ -1235,6 +1236,7 @@ fn script_for_p2wpkh(key: &PublicKey) -> Script {
12351236
mod tests {
12361237
use super::CounterpartyCommitmentSecrets;
12371238
use hex;
1239+
use prelude::*;
12381240

12391241
#[test]
12401242
fn test_per_commitment_storage() {

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use ln::functional_test_utils::*;
3838

3939
use util::test_utils;
4040

41+
use prelude::*;
4142
use std::collections::HashMap;
4243

4344
// If persister_fail is true, we have the persister return a PermanentFailure

lightning/src/ln/channel.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use util::errors::APIError;
4040
use util::config::{UserConfig,ChannelConfig};
4141
use util::scid_utils::scid_from_parts;
4242

43+
use prelude::*;
4344
use core::{cmp,mem,fmt};
4445
use core::ops::Deref;
4546
#[cfg(any(test, feature = "fuzztarget"))]
@@ -4928,6 +4929,7 @@ mod tests {
49284929
use bitcoin::hashes::Hash;
49294930
use bitcoin::hash_types::{Txid, WPubkeyHash};
49304931
use std::sync::Arc;
4932+
use prelude::*;
49314933

49324934
struct TestFeeEstimator {
49334935
fee_est: u32

0 commit comments

Comments
 (0)