Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit 9387750

Browse files
committed
Update validator to rust 2021
Signed-off-by: Joseph Livesey <joseph.livesey@btp.works>
1 parent e61308d commit 9387750

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+248
-253
lines changed

validator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sawtooth_validator"
33
version = "1.3.0"
44
authors = ["Intel Corporation"]
5+
edition = '2021'
56

67
[dependencies]
78
clap = "2"

validator/src/batch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
* ------------------------------------------------------------------------------
1616
*/
1717

18-
use proto;
18+
use crate::proto;
1919
use protobuf::{self, Message};
2020

21-
use transaction::Transaction;
21+
use crate::transaction::Transaction;
2222

2323
#[derive(Clone, Debug, PartialEq)]
2424
pub struct Batch {

validator/src/batch_ffi.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
* ------------------------------------------------------------------------------
1616
*/
1717

18-
use cpython;
1918
use cpython::FromPyObject;
2019
use cpython::ObjectProtocol;
2120
use cpython::PythonObject;
2221
use cpython::ToPyObject;
2322
use protobuf::Message;
2423

25-
use batch::Batch;
26-
use proto;
27-
use transaction::Transaction;
24+
use crate::batch::Batch;
25+
use crate::proto;
26+
use crate::transaction::Transaction;
2827

2928
impl ToPyObject for Batch {
3029
type ObjectType = cpython::PyObject;
@@ -118,11 +117,10 @@ impl<'source> FromPyObject<'source> for Batch {
118117
mod tests {
119118

120119
use super::Batch;
121-
use cpython;
120+
use crate::proto;
121+
use crate::transaction::Transaction;
122122
use cpython::ToPyObject;
123-
use proto;
124123
use protobuf::Message;
125-
use transaction::Transaction;
126124

127125
fn create_batch() -> Batch {
128126
let mut batch_header = proto::batch::BatchHeader::new();

validator/src/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* ------------------------------------------------------------------------------
1616
*/
1717

18-
use batch::Batch;
19-
use proto;
18+
use crate::batch::Batch;
19+
use crate::proto;
2020
use protobuf::{self, Message};
2121
use std::fmt;
2222

validator/src/block_ffi.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@
1414
* limitations under the License.
1515
* ------------------------------------------------------------------------------
1616
*/
17-
use batch::Batch;
18-
use block::Block;
19-
use cpython;
17+
use crate::batch::Batch;
18+
use crate::block::Block;
19+
use crate::proto::batch::Batch as ProtoBatch;
20+
use crate::proto::batch::BatchHeader;
21+
use crate::proto::block::Block as ProtoBlock;
22+
use crate::proto::block::BlockHeader;
23+
use crate::proto::transaction::Transaction as ProtoTxn;
24+
use crate::proto::transaction::TransactionHeader;
25+
use crate::transaction::Transaction;
2026
use cpython::{FromPyObject, ObjectProtocol, PyObject, Python, PythonObject, ToPyObject};
21-
use proto::batch::Batch as ProtoBatch;
22-
use proto::batch::BatchHeader;
23-
use proto::block::Block as ProtoBlock;
24-
use proto::block::BlockHeader;
25-
use proto::transaction::Transaction as ProtoTxn;
26-
use proto::transaction::TransactionHeader;
27-
use protobuf;
2827
use protobuf::Message;
29-
use transaction::Transaction;
3028

3129
impl<'source> FromPyObject<'source> for Block {
3230
fn extract(py: Python, obj: &'source PyObject) -> cpython::PyResult<Self> {

validator/src/consensus/notifier.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ use std::sync::mpsc::{channel, Sender};
1919
use std::sync::{Arc, Mutex};
2020
use std::thread;
2121

22-
use block::Block;
22+
use crate::block::Block;
2323

24-
use hashlib::sha256_digest_strs;
24+
use crate::hashlib::sha256_digest_strs;
2525
use hex;
2626
use protobuf::{Message, RepeatedField};
2727

28-
use proto::consensus::{
28+
use crate::proto::consensus::{
2929
ConsensusBlock, ConsensusNotifyBlockCommit, ConsensusNotifyBlockInvalid,
3030
ConsensusNotifyBlockNew, ConsensusNotifyBlockValid, ConsensusNotifyEngineActivated,
3131
ConsensusNotifyEngineDeactivated, ConsensusNotifyPeerConnected,
3232
ConsensusNotifyPeerDisconnected, ConsensusNotifyPeerMessage, ConsensusPeerInfo,
3333
ConsensusPeerMessage,
3434
};
35-
use proto::validator::Message_MessageType as MessageType;
35+
use crate::proto::validator::Message_MessageType as MessageType;
3636

3737
pub trait ConsensusNotifier: Send + Sync {
3838
fn notify_peer_connected(&self, peer_id: &str);

validator/src/consensus/notifier_ffi.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ use cpython::{NoArgs, ObjectProtocol, PyClone, PyObject, Python};
2323
use protobuf::{Message, ProtobufEnum};
2424
use py_ffi;
2525

26-
use block::Block;
27-
use consensus::notifier::{
26+
use crate::block::Block;
27+
use crate::consensus::notifier::{
2828
BackgroundConsensusNotifier, ConsensusNotifier, NotifierService, NotifierServiceError,
2929
};
30-
use proto::validator::Message_MessageType as MessageType;
31-
use proto::{self, consensus::ConsensusPeerMessage};
32-
use pylogger;
30+
use crate::proto::validator::Message_MessageType as MessageType;
31+
use crate::proto::{self, consensus::ConsensusPeerMessage};
32+
use crate::pylogger;
3333

3434
pub struct PyNotifierService {
3535
py_notifier_service: PyObject,

validator/src/consensus/registry_ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
use cpython::{NoArgs, ObjectProtocol, PyClone, PyObject, Python};
1919

20-
use consensus::registry::{ConsensusRegistry, ConsensusRegistryError, EngineInfo};
21-
use pylogger;
20+
use crate::consensus::registry::{ConsensusRegistry, ConsensusRegistryError, EngineInfo};
21+
use crate::pylogger;
2222

2323
pub struct PyConsensusRegistry {
2424
py_consensus_registry: PyObject,

validator/src/database/lmdb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::sync::Arc;
2121

2222
use lmdb_zero as lmdb;
2323

24-
use database::error::DatabaseError;
24+
use crate::database::error::DatabaseError;
2525

2626
const DEFAULT_SIZE: usize = 1 << 40; // 1024 ** 4
2727

validator/src/database/lmdb_ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
* ------------------------------------------------------------------------------
1616
*/
17+
use crate::database::lmdb::*;
1718
use cpython::{PyList, PyObject, Python};
18-
use database::lmdb::*;
1919
use py_ffi;
2020
use std::ffi::CStr;
2121
use std::os::raw::{c_char, c_void};

0 commit comments

Comments
 (0)