Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Updates for new rustc #198

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(use_extern_macros)]

extern crate protobuf;
extern crate serde;

Expand Down
2 changes: 0 additions & 2 deletions benchmark/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(use_extern_macros)]

#[macro_use]
extern crate clap;
use clap::{App, Arg};
Expand Down
2 changes: 0 additions & 2 deletions gateway/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

//! web3 gateway for Oasis Ethereum runtime.

#![feature(use_extern_macros)]

extern crate ctrlc;
extern crate fdlimit;
extern crate log;
Expand Down
2 changes: 0 additions & 2 deletions gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

//! Ethcore client application.

#![feature(use_extern_macros)]

#[macro_use]
extern crate clap;
extern crate env_logger;
Expand Down
7 changes: 6 additions & 1 deletion gateway/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Read-only interface to blockchain and account state, backed by an Ekiden Database.

use std::marker::{Send, Sync};
use std::mem;
use std::sync::Arc;

use common_types::log_entry::{LocalizedLogEntry, LogEntry};
Expand Down Expand Up @@ -257,12 +258,16 @@ where
}
}

pub fn to_bytes(num: u32) -> [u8; mem::size_of::<u32>()] {
unsafe { mem::transmute(num) }
}

// Parity expects the database to namespace keys by column. The Ekiden db
// doesn't [yet?] have this feature, so we emulate by prepending the column id
// to the actual key. Columns None and 0 should be distinct, so we use prefix 0
// for None and col+1 for Some(col).
pub fn get_key(col: Option<u32>, key: &[u8]) -> Vec<u8> {
let col_bytes = col.map(|id| (id + 1).to_le().to_bytes())
let col_bytes = col.map(|id| to_bytes((id + 1).to_le()))
.unwrap_or([0, 0, 0, 0]);
col_bytes
.into_iter()
Expand Down
1 change: 0 additions & 1 deletion genesis/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(use_extern_macros)]
use std::collections::HashMap;
use std::str::FromStr;

Expand Down
2 changes: 0 additions & 2 deletions playback/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(use_extern_macros)]

extern crate ethereum_types;
#[macro_use]
extern crate clap;
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![feature(iterator_try_fold)]
#![feature(use_extern_macros)]

extern crate common_types as ethcore_types;
extern crate ekiden_common;
extern crate ekiden_core;
Expand Down
7 changes: 6 additions & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{collections::HashSet,
mem,
ops::Deref,
sync::{Arc, Mutex}};

Expand Down Expand Up @@ -368,12 +369,16 @@ fn to_block_id(id: EkidenBlockId) -> BlockId {
}
}

pub fn to_bytes(num: u32) -> [u8; mem::size_of::<u32>()] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunate that this got removed. It looks like the deal is that they're moving to a to_le_bytes() API, but i guess the state at this nightly is that neither are stable?

Can you add a comment pointing to the language issue: rust-lang/rust#52963 so that we can get rid of this once .to_le_bytes is available?

unsafe { mem::transmute(num) }
}

// Parity expects the database to namespace keys by column. The Ekiden db
// doesn't [yet?] have this feature, so we emulate by prepending the column id
// to the actual key. Columns None and 0 should be distinct, so we use prefix 0
// for None and col+1 for Some(col).
fn get_key(col: Option<u32>, key: &[u8]) -> Vec<u8> {
let col_bytes = col.map(|id| (id + 1).to_le().to_bytes())
let col_bytes = col.map(|id| to_bytes((id + 1).to_le()))
.unwrap_or([0, 0, 0, 0]);
col_bytes
.into_iter()
Expand Down