-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no_std support #528
no_std support #528
Changes from 1 commit
15cb1c5
cab8669
018fd06
1e1f29a
be0d332
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,8 @@ | |
//! these blocks and the blockchain. | ||
//! | ||
|
||
use std::fmt; | ||
use core::fmt; | ||
use alloc::vec::Vec; | ||
|
||
use util; | ||
use util::Error::{BlockBadTarget, BlockBadProofOfWork}; | ||
|
@@ -308,12 +309,14 @@ impl fmt::Display for Bip34Error { | |
} | ||
} | ||
|
||
impl ::std::error::Error for Bip34Error {} | ||
#[cfg(feature = "std")] | ||
impl std::error::Error for Bip34Error {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite understand what a lack of an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not too much. The whole Error concept is std-only usually. The |
||
|
||
#[cfg(test)] | ||
mod tests { | ||
use hashes::hex::FromHex; | ||
|
||
use alloc::{vec::Vec, string::ToString}; | ||
use blockdata::block::{Block, BlockHeader}; | ||
use consensus::encode::{deserialize, serialize}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ | |
//! single transaction | ||
//! | ||
|
||
use std::default::Default; | ||
use core::default::Default; | ||
use alloc::vec::Vec; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it's possible to avoid bumping MSRV if |
||
|
||
use hashes::hex::FromHex; | ||
use hashes::sha256d; | ||
|
@@ -159,7 +160,8 @@ pub fn genesis_block(network: Network) -> Block { | |
|
||
#[cfg(test)] | ||
mod test { | ||
use std::default::Default; | ||
use core::default::Default; | ||
use alloc::{vec::Vec, string::ToString}; | ||
use hashes::hex::FromHex; | ||
|
||
use network::constants::Network; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
|
||
#[cfg(feature = "serde")] use serde; | ||
|
||
use std::fmt; | ||
use core::{fmt, convert::From}; | ||
|
||
// Note: I am deliberately not implementing PartialOrd or Ord on the | ||
// opcode enum. If you want to check ranges of opcodes, etc., | ||
|
@@ -816,7 +816,7 @@ impl Ordinary { | |
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::collections::HashSet; | ||
use alloc::collections::BTreeSet; | ||
|
||
use super::*; | ||
|
||
|
@@ -834,7 +834,7 @@ mod tests { | |
|
||
#[test] | ||
fn str_roundtrip() { | ||
let mut unique = HashSet::new(); | ||
let mut unique = BTreeSet::new(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not be needed in tests, there's no point in making tests |
||
roundtrip!(unique, OP_PUSHBYTES_0); | ||
roundtrip!(unique, OP_PUSHBYTES_1); | ||
roundtrip!(unique, OP_PUSHBYTES_2); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hacky fork to get things working