diff --git a/Cargo.lock b/Cargo.lock index 072734445face7a5adf2cca89ffb99c580498f1b..44d81fceec9f84699d51523256845f2ac8499af1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,7 +196,7 @@ dependencies = [ "duniter-message 0.1.0-a0.1", "duniter-module 0.1.0-a0.1", "duniter-network 0.1.0-a0.1", - "duniter-wotb 0.8.0-a0.7", + "durs-wot 0.8.0-a0.8", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -265,7 +265,7 @@ dependencies = [ "duniter-documents 0.8.0-a0.1", "duniter-module 0.1.0-a0.1", "duniter-network 0.1.0-a0.1", - "duniter-wotb 0.8.0-a0.7", + "durs-wot 0.8.0-a0.8", "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -357,17 +357,6 @@ dependencies = [ "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "duniter-wotb" -version = "0.8.0-a0.7" -dependencies = [ - "bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "durs" version = "0.1.0-a0.1" @@ -379,6 +368,17 @@ dependencies = [ "structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "durs-wot" +version = "0.8.0-a0.8" +dependencies = [ + "bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "durs-ws2p" version = "0.1.0-a0.1" @@ -425,7 +425,7 @@ dependencies = [ "duniter-message 0.1.0-a0.1", "duniter-module 0.1.0-a0.1", "duniter-network 0.1.0-a0.1", - "duniter-wotb 0.8.0-a0.7", + "durs-wot 0.8.0-a0.8", "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 60a612ea17bcba1f4ea104e8e468a896ec7ab306..53541ce5706cbc7923ee807b52718bdb6097ff9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ members = [ "module", "network", "tui", - "wotb", + "wot", "ws2p", "ws2p-messages", "ws2p-v1-legacy" diff --git a/blockchain/Cargo.toml b/blockchain/Cargo.toml index 44ba92d6d331c74c010fbdc6c94ce9b457cc6f78..a4be6dacb8599541eb09e6d766118795af1b6a42 100644 --- a/blockchain/Cargo.toml +++ b/blockchain/Cargo.toml @@ -17,7 +17,7 @@ duniter-documents = { path = "../documents" } duniter-message = { path = "../message" } duniter-module = { path = "../module" } duniter-network = { path = "../network" } -duniter-wotb = { path = "../wotb" } +durs-wot = { path = "../wot" } log = "0.4.*" num_cpus = "1.8.*" pbr = "1.0.*" diff --git a/blockchain/apply_valid_block.rs b/blockchain/apply_valid_block.rs index f731e93a41da8ffc6e86621cc5333ea33e1b0066..69e72f3059f5292d8f2c63110cde29a5bdaf6221 100644 --- a/blockchain/apply_valid_block.rs +++ b/blockchain/apply_valid_block.rs @@ -22,8 +22,8 @@ use duniter_documents::blockchain::v10::documents::transaction::{TxAmount, TxBas use duniter_documents::blockchain::v10::documents::BlockDocument; use duniter_documents::blockchain::Document; use duniter_documents::BlockId; -use duniter_wotb::data::{NewLinkResult, RemLinkResult}; -use duniter_wotb::{NodeId, WebOfTrust}; +use durs_wot::data::{NewLinkResult, RemLinkResult}; +use durs_wot::{NodeId, WebOfTrust}; use std::collections::{HashMap, HashSet}; #[derive(Debug)] @@ -63,7 +63,7 @@ pub fn apply_valid_block<W: WebOfTrust>( let pubkey = joiner.clone().issuers()[0]; if let Some(idty_doc) = identities.get(&pubkey) { // Newcomer - let wotb_id = NodeId( + let wot_id = NodeId( wot_db .read(|db| db.size()) .expect("Fatal error : fail to read WotDB !"), @@ -73,9 +73,9 @@ pub fn apply_valid_block<W: WebOfTrust>( db.add_node(); }) .expect("Fail to write in WotDB"); - wot_index.insert(pubkey, wotb_id); + wot_index.insert(pubkey, wot_id); wot_dbs_requests.push(WotsDBsWriteQuery::CreateIdentity( - wotb_id, + wot_id, current_blockstamp, block.median_time, Box::new(idty_doc.clone()), @@ -83,15 +83,15 @@ pub fn apply_valid_block<W: WebOfTrust>( )); } else { // Renewer - let wotb_id = wot_index[&joiner.issuers()[0]]; + let wot_id = wot_index[&joiner.issuers()[0]]; wot_db .write(|db| { - db.set_enabled(wotb_id, true); + db.set_enabled(wot_id, true); }) .expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RenewalIdentity( joiner.issuers()[0], - wotb_id, + wot_id, block.median_time, joiner.blockstamp().id, )); @@ -100,15 +100,15 @@ pub fn apply_valid_block<W: WebOfTrust>( for active in block.actives.clone() { let pubkey = active.issuers()[0]; if !identities.contains_key(&pubkey) { - let wotb_id = wot_index[&pubkey]; + let wot_id = wot_index[&pubkey]; wot_db .write(|db| { - db.set_enabled(wotb_id, true); + db.set_enabled(wot_id, true); }) .expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RenewalIdentity( pubkey, - wotb_id, + wot_id, block.median_time, active.blockstamp().id, )); @@ -151,24 +151,24 @@ pub fn apply_valid_block<W: WebOfTrust>( for certification in block.certifications.clone() { trace!("stack_up_valid_block: apply cert..."); let compact_cert = certification.to_compact_document(); - let wotb_node_from = wot_index[&compact_cert.issuer]; - let wotb_node_to = wot_index[&compact_cert.target]; + let wot_node_from = wot_index[&compact_cert.issuer]; + let wot_node_to = wot_index[&compact_cert.target]; wot_db .write(|db| { - let result = db.add_link(wotb_node_from, wotb_node_to); + let result = db.add_link(wot_node_from, wot_node_to); match result { NewLinkResult::Ok(_) => {} _ => panic!( "Fail to add_link {}->{} : {:?}", - wotb_node_from.0, wotb_node_to.0, result + wot_node_from.0, wot_node_to.0, result ), } }) .expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::CreateCert( compact_cert.issuer, - wotb_node_from, - wotb_node_to, + wot_node_from, + wot_node_to, compact_cert.block_number, block.median_time, )); @@ -198,8 +198,8 @@ pub fn apply_valid_block<W: WebOfTrust>( .read(|db| db.get_enabled()) .expect("Fail to read WotDB"); let mut members_pubkeys = Vec::new(); - for (pubkey, wotb_id) in wot_index { - if members_wot_ids.contains(wotb_id) { + for (pubkey, wot_id) in wot_index { + if members_wot_ids.contains(wot_id) { members_pubkeys.push(*pubkey); } } diff --git a/blockchain/check_and_apply_block.rs b/blockchain/check_and_apply_block.rs index 9851bf29fcd754eb51ad09e17e4948eb86e45eff..3c601f47215dff775a375b3c7f6971d44d2ce3ee 100644 --- a/blockchain/check_and_apply_block.rs +++ b/blockchain/check_and_apply_block.rs @@ -58,7 +58,7 @@ pub fn check_and_apply_block<W: WebOfTrust>( certs_db: &BinDB<CertsExpirV10Datas>, block: &Block, current_blockstamp: &Blockstamp, - wotb_index: &mut HashMap<PubKey, NodeId>, + wot_index: &mut HashMap<PubKey, NodeId>, wot_db: &BinDB<W>, forks_states: &[ForkStatus], ) -> Result<ValidBlockApplyReqs, BlockError> { @@ -101,7 +101,7 @@ pub fn check_and_apply_block<W: WebOfTrust>( }; return Ok(apply_valid_block( &block_doc, - wotb_index, + wot_index, wot_db, &expire_certs, old_fork_id, diff --git a/blockchain/dbex.rs b/blockchain/dbex.rs index 5ee9908efa21706be19c766f7133d724c608710e..34ede624a757e188ef0d2042b296e38940ed4a7d 100644 --- a/blockchain/dbex.rs +++ b/blockchain/dbex.rs @@ -17,8 +17,8 @@ use duniter_crypto::keys::*; use duniter_dal::identity::DALIdentity; use duniter_documents::blockchain::v10::documents::transaction::*; use duniter_module::DuniterConf; -use duniter_wotb::data::rusty::RustyWebOfTrust; -use duniter_wotb::operations::distance::{DistanceCalculator, WotDistance, WotDistanceParameters}; +use durs_wot::data::rusty::RustyWebOfTrust; +use durs_wot::operations::distance::{DistanceCalculator, WotDistance, WotDistanceParameters}; use std::time::*; use *; @@ -140,7 +140,7 @@ pub fn dbex_wot<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DB .expect("Fail to parse currency params !"); // get wot_index - let wot_index = DALIdentity::get_wotb_index(&wot_databases.identities_db).expect("DALError"); + let wot_index = DALIdentity::get_wot_index(&wot_databases.identities_db).expect("DALError"); // get wot_reverse_index let wot_reverse_index: HashMap<NodeId, &PubKey> = diff --git a/blockchain/lib.rs b/blockchain/lib.rs index 82d44187b27d3de253e29bb74e21e4736c33b9a8..f365db83279061256958cd27d4b910cc087ca44c 100644 --- a/blockchain/lib.rs +++ b/blockchain/lib.rs @@ -40,7 +40,7 @@ extern crate duniter_documents; extern crate duniter_message; extern crate duniter_module; extern crate duniter_network; -extern crate duniter_wotb; +extern crate durs_wot; extern crate serde; extern crate serde_json; extern crate sqlite; @@ -78,9 +78,9 @@ use duniter_module::*; use duniter_network::{ NetworkBlock, NetworkDocument, NetworkEvent, NetworkResponse, NodeFullId, OldNetworkRequest, }; -use duniter_wotb::data::rusty::RustyWebOfTrust; -use duniter_wotb::operations::distance::RustyDistanceCalculator; -use duniter_wotb::{NodeId, WebOfTrust}; +use durs_wot::data::rusty::RustyWebOfTrust; +use durs_wot::operations::distance::RustyDistanceCalculator; +use durs_wot::{NodeId, WebOfTrust}; /// The blocks are requested by packet groups. This constant sets the block packet size. pub static CHUNK_SIZE: &'static u32 = &50; @@ -304,7 +304,7 @@ impl BlockchainModule { &mut self, network_documents: &[NetworkDocument], current_blockstamp: &Blockstamp, - wotb_index: &mut HashMap<PubKey, NodeId>, + wot_index: &mut HashMap<PubKey, NodeId>, wot_db: &BinDB<W>, ) -> Blockstamp { let mut blockchain_documents = Vec::new(); @@ -320,7 +320,7 @@ impl BlockchainModule { &self.wot_databases.certs_db, &Block::NetworkBlock(network_block), ¤t_blockstamp, - wotb_index, + wot_index, wot_db, &self.forks_states, ) { @@ -439,7 +439,7 @@ impl BlockchainModule { &mut self, blocks_in_box: &[Box<NetworkBlock>], current_blockstamp: &Blockstamp, - wotb_index: &mut HashMap<PubKey, NodeId>, + wot_index: &mut HashMap<PubKey, NodeId>, wot: &BinDB<W>, ) -> Blockstamp { debug!("BlockchainModule : receive_blocks()"); @@ -455,7 +455,7 @@ impl BlockchainModule { &self.wot_databases.certs_db, &Block::NetworkBlock(block), ¤t_blockstamp, - wotb_index, + wot_index, wot, &self.forks_states, ) { @@ -508,10 +508,10 @@ impl BlockchainModule { // Get dbs path let dbs_path = duniter_conf::get_blockchain_db_path(self.profile.as_str(), &self.currency); - // Get wotb index - let mut wotb_index: HashMap<PubKey, NodeId> = - DALIdentity::get_wotb_index(&self.wot_databases.identities_db) - .expect("Fatal eror : get_wotb_index : Fail to read blockchain databases"); + // Get wot index + let mut wot_index: HashMap<PubKey, NodeId> = + DALIdentity::get_wot_index(&self.wot_databases.identities_db) + .expect("Fatal eror : get_wot_index : Fail to read blockchain databases"); // Open wot file let wot_db = open_wot_db::<RustyWebOfTrust>(Some(&dbs_path)).expect("Fail to open WotDB !"); @@ -629,7 +629,7 @@ impl BlockchainModule { let new_current_blockstamp = self.receive_network_documents( network_docs, ¤t_blockstamp, - &mut wotb_index, + &mut wot_index, &wot_db, ); current_blockstamp = new_current_blockstamp; @@ -665,7 +665,7 @@ impl BlockchainModule { ); revert_block::revert_block( &last_dal_block, - &mut wotb_index, + &mut wot_index, &wot_db, Some(free_fork_id), &self @@ -686,7 +686,7 @@ impl BlockchainModule { let new_current_blockstamp = self.receive_blocks( blocks, ¤t_blockstamp, - &mut wotb_index, + &mut wot_index, &wot_db, ); if current_blockstamp != new_current_blockstamp { @@ -748,7 +748,7 @@ impl BlockchainModule { &self.wot_databases.certs_db, &Block::LocalBlock(&stackable_block.block), ¤t_blockstamp, - &mut wotb_index, + &mut wot_index, &wot_db, &self.forks_states, ) { diff --git a/blockchain/revert_block.rs b/blockchain/revert_block.rs index 4ac1e0f48bebd0cfdfc1ade1033dd60e41e271cc..3ea7afc0bc654a0c3ea142a5fbb3766444dc4322 100644 --- a/blockchain/revert_block.rs +++ b/blockchain/revert_block.rs @@ -22,8 +22,8 @@ use duniter_dal::{BinDB, ForkId, TxV10Datas}; use duniter_documents::blockchain::v10::documents::block::TxDocOrTxHash; use duniter_documents::blockchain::v10::documents::transaction::{TxAmount, TxBase}; use duniter_documents::blockchain::Document; -use duniter_wotb::data::{NewLinkResult, RemLinkResult}; -use duniter_wotb::{NodeId, WebOfTrust}; +use durs_wot::data::{NewLinkResult, RemLinkResult}; +use durs_wot::{NodeId, WebOfTrust}; use std::collections::HashMap; #[derive(Debug)] @@ -85,8 +85,8 @@ pub fn revert_block<W: WebOfTrust>( .read(|db| db.get_enabled()) .expect("Fail to read WotDB"); let mut members_pubkeys = Vec::new(); - for (pubkey, wotb_id) in wot_index.iter() { - if members_wot_ids.contains(wotb_id) { + for (pubkey, wot_id) in wot_index.iter() { + if members_wot_ids.contains(wot_id) { members_pubkeys.push(*pubkey); } } @@ -122,24 +122,24 @@ pub fn revert_block<W: WebOfTrust>( for certification in block.certifications.clone() { trace!("stack_up_valid_block: apply cert..."); let compact_cert = certification.to_compact_document(); - let wotb_node_from = wot_index[&compact_cert.issuer]; - let wotb_node_to = wot_index[&compact_cert.target]; + let wot_node_from = wot_index[&compact_cert.issuer]; + let wot_node_to = wot_index[&compact_cert.target]; wot_db .write(|db| { - let result = db.rem_link(wotb_node_from, wotb_node_to); + let result = db.rem_link(wot_node_from, wot_node_to); match result { RemLinkResult::Removed(_) => {} _ => panic!( "Fail to rem_link {}->{} : {:?}", - wotb_node_from.0, wotb_node_to.0, result + wot_node_from.0, wot_node_to.0, result ), } }) .expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertCert( compact_cert, - wotb_node_from, - wotb_node_to, + wot_node_from, + wot_node_to, )); trace!("stack_up_valid_block: apply cert...success."); } @@ -188,15 +188,15 @@ pub fn revert_block<W: WebOfTrust>( for active in block.actives.clone() { let pubkey = active.issuers()[0]; if !identities.contains_key(&pubkey) { - let wotb_id = wot_index[&pubkey]; + let wot_id = wot_index[&pubkey]; wot_db .write(|db| { - db.set_enabled(wotb_id, true); + db.set_enabled(wot_id, true); }) .expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertRenewalIdentity( pubkey, - wotb_id, + wot_id, block.median_time, active.blockstamp().id, )); @@ -216,15 +216,15 @@ pub fn revert_block<W: WebOfTrust>( wot_dbs_requests.push(WotsDBsWriteQuery::RevertCreateIdentity(pubkey)); } else { // Renewer - let wotb_id = wot_index[&joiner.issuers()[0]]; + let wot_id = wot_index[&joiner.issuers()[0]]; wot_db .write(|db| { - db.set_enabled(wotb_id, true); + db.set_enabled(wot_id, true); }) .expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertRenewalIdentity( joiner.issuers()[0], - wotb_id, + wot_id, block.median_time, joiner.blockstamp().id, )); diff --git a/blockchain/sync.rs b/blockchain/sync.rs index 1bcd942b4a3c49c6809676b3f6c5474c38cc4471..47b68cefc8cc0f58fdfce65188192385717b1108 100644 --- a/blockchain/sync.rs +++ b/blockchain/sync.rs @@ -27,7 +27,7 @@ use duniter_dal::writers::requests::*; use duniter_dal::ForkId; use duniter_documents::{BlockHash, BlockId}; use duniter_network::NetworkBlock; -use duniter_wotb::NodeId; +use durs_wot::NodeId; use std::collections::{HashMap, VecDeque}; use std::fs; use std::ops::Deref; @@ -279,10 +279,10 @@ pub fn sync_ts<DC: DuniterConf>( return; } - // Get wotb index - let mut wotb_index: HashMap<PubKey, NodeId> = - DALIdentity::get_wotb_index(&wot_databases.identities_db) - .expect("Fatal eror : get_wotb_index : Fail to read blockchain databases"); + // Get wot index + let mut wot_index: HashMap<PubKey, NodeId> = + DALIdentity::get_wot_index(&wot_databases.identities_db) + .expect("Fatal eror : get_wot_index : Fail to read blockchain databases"); // Start sync let sync_start_time = SystemTime::now(); @@ -535,7 +535,7 @@ pub fn sync_ts<DC: DuniterConf>( if let Ok(ValidBlockApplyReqs(block_req, wot_db_reqs, currency_db_reqs)) = apply_valid_block::<RustyWebOfTrust>( &block_doc, - &mut wotb_index, + &mut wot_index, &wot_db, &expire_certs, None, @@ -624,7 +624,7 @@ pub fn sync_ts<DC: DuniterConf>( currency_params_db.save().expect("Fail to save params db"); // Save wot file - wot_db.save().expect("Fail to save wotb db"); + wot_db.save().expect("Fail to save wot db"); let main_job_duration = SystemTime::now().duration_since(main_job_begin).unwrap() - all_wait_duration; diff --git a/dal/Cargo.toml b/dal/Cargo.toml index fd9d280d275e4d1f2dd793cd2068127a4cf56ab8..535bf8557687ae2731684883124426809d997f91 100644 --- a/dal/Cargo.toml +++ b/dal/Cargo.toml @@ -13,7 +13,7 @@ duniter-crypto = { path = "../crypto" } duniter-documents = { path = "../documents" } duniter-module = { path = "../module" } duniter-network = { path = "../network" } -duniter-wotb = { path = "../wotb" } +durs-wot = { path = "../wot" } lazy_static = "1.0.*" log = "0.4.*" rand = "0.4.*" diff --git a/dal/block.rs b/dal/block.rs index 8ca38a5388f0b3b7e21a325c3bed44d3bf363670..0b0128cd4fe3a58cc32e2c846c53e232fc6433fe 100644 --- a/dal/block.rs +++ b/dal/block.rs @@ -18,7 +18,7 @@ use duniter_crypto::keys::*; use duniter_documents::blockchain::v10::documents::BlockDocument; use duniter_documents::blockchain::Document; use duniter_documents::{BlockHash, BlockId, Blockstamp, PreviousBlockstamp}; -use duniter_wotb::NodeId; +use durs_wot::NodeId; use std::collections::HashMap; use *; diff --git a/dal/certs.rs b/dal/certs.rs index fea1325eb231a1a775bffc6f13d48ac71eff17d0..532ceeae8f6f756c4ffe462cff19491b41d01e50 100644 --- a/dal/certs.rs +++ b/dal/certs.rs @@ -14,10 +14,10 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. extern crate duniter_documents; -extern crate duniter_wotb; +extern crate durs_wot; use duniter_documents::BlockId; -use duniter_wotb::NodeId; +use durs_wot::NodeId; use std::collections::HashMap; use {BinDB, CertsExpirV10Datas, DALError}; diff --git a/dal/identity.rs b/dal/identity.rs index 03467a869814d51c3314612337b4d8791b9b1880..30d36b4e7b0ccd0392085948173f18d9210a25c9 100644 --- a/dal/identity.rs +++ b/dal/identity.rs @@ -17,7 +17,7 @@ use currency_params::CurrencyParameters; use duniter_crypto::keys::*; use duniter_documents::blockchain::v10::documents::IdentityDocument; use duniter_documents::{BlockId, Blockstamp}; -use duniter_wotb::NodeId; +use durs_wot::NodeId; use std::collections::HashMap; use {BinDB, DALError, IdentitiesV10Datas, MsExpirV10Datas}; @@ -129,16 +129,16 @@ impl DALIdentity { } /// Get wot_id index - pub fn get_wotb_index( + pub fn get_wot_index( identities_db: &BinDB<IdentitiesV10Datas>, ) -> Result<HashMap<PubKey, NodeId>, DALError> { Ok(identities_db.read(|db| { - let mut wotb_index: HashMap<PubKey, NodeId> = HashMap::new(); + let mut wot_index: HashMap<PubKey, NodeId> = HashMap::new(); for (pubkey, member_datas) in db { - let wotb_id = member_datas.wot_id; - wotb_index.insert(*pubkey, wotb_id); + let wot_id = member_datas.wot_id; + wot_index.insert(*pubkey, wot_id); } - wotb_index + wot_index })?) } diff --git a/dal/lib.rs b/dal/lib.rs index 8cceb24b9f19e691ab3a15735f688707130357bd..9ba82ae0008e4332be7ade252de707931a8f018a 100644 --- a/dal/lib.rs +++ b/dal/lib.rs @@ -39,7 +39,7 @@ extern crate serde_derive; extern crate duniter_crypto; extern crate duniter_documents; -extern crate duniter_wotb; +extern crate durs_wot; extern crate rustbreak; extern crate serde; @@ -85,7 +85,7 @@ use duniter_documents::blockchain::v10::documents::block::BlockV10Parameters; use duniter_documents::blockchain::v10::documents::transaction::*; use duniter_documents::CurrencyName; use duniter_documents::{BlockHash, BlockId, Blockstamp, PreviousBlockstamp}; -use duniter_wotb::{NodeId, WebOfTrust}; +use durs_wot::{NodeId, WebOfTrust}; use rustbreak::backend::{FileBackend, MemoryBackend}; use rustbreak::error::{RustbreakError, RustbreakErrorKind}; use rustbreak::{deser::Bincode, Database, FileDatabase, MemoryDatabase}; @@ -478,7 +478,7 @@ pub fn open_db<D: Serialize + DeserializeOwned + Debug + Default + Clone + Send> } } -/// Open wot db (cf. duniter-wot crate) +/// Open wot db (cf. durs-wot crate) pub fn open_wot_db<W: WebOfTrust>(dbs_folder_path: Option<&PathBuf>) -> Result<BinDB<W>, DALError> { if let Some(dbs_folder_path) = dbs_folder_path { Ok(BinDB::File(open_db::<W>(dbs_folder_path, "wot.db")?)) diff --git a/dal/tools.rs b/dal/tools.rs index b3509912f6ec8d926565c071b81537cc5690dcda..12a91949f8c04e64ad549bc1f3d0a085946c40d4 100644 --- a/dal/tools.rs +++ b/dal/tools.rs @@ -13,15 +13,13 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -extern crate duniter_wotb; +extern crate durs_wot; -use duniter_wotb::operations::centrality::{ - CentralitiesCalculator, UlrikBrandesCentralityCalculator, -}; -use duniter_wotb::operations::distance::{ +use durs_wot::operations::centrality::{CentralitiesCalculator, UlrikBrandesCentralityCalculator}; +use durs_wot::operations::distance::{ DistanceCalculator, RustyDistanceCalculator, WotDistance, WotDistanceParameters, }; -use duniter_wotb::{NodeId, WebOfTrust}; +use durs_wot::{NodeId, WebOfTrust}; /// CENTRALITY_CALCULATOR pub static CENTRALITY_CALCULATOR: UlrikBrandesCentralityCalculator = diff --git a/dal/writers/certification.rs b/dal/writers/certification.rs index 7ac57ac1629e482421a79568f1c4edbf734b4d33..bb01dfd1a793267f7907515312a24944a98f3335 100644 --- a/dal/writers/certification.rs +++ b/dal/writers/certification.rs @@ -20,7 +20,7 @@ use currency_params::CurrencyParameters; use duniter_crypto::keys::*; use duniter_documents::blockchain::v10::documents::certification::CompactCertificationDocument; use duniter_documents::BlockId; -use duniter_wotb::NodeId; +use durs_wot::NodeId; use {BinDB, CertsExpirV10Datas, DALError, IdentitiesV10Datas}; /// Apply "certification" event in databases diff --git a/dal/writers/identity.rs b/dal/writers/identity.rs index 454f3d51b680ba2c8f1d2e519c4cc9a9d6ff9b2b..93f2bef0b3936c7c04803aa4ef9664504b4e815d 100644 --- a/dal/writers/identity.rs +++ b/dal/writers/identity.rs @@ -18,7 +18,7 @@ use duniter_crypto::keys::PubKey; use duniter_documents::blockchain::v10::documents::IdentityDocument; use duniter_documents::blockchain::Document; use duniter_documents::{BlockId, Blockstamp}; -use duniter_wotb::NodeId; +use durs_wot::NodeId; use identity::{DALIdentity, DALIdentityState}; use {BinDB, DALError, IdentitiesV10Datas, MsExpirV10Datas}; diff --git a/dal/writers/requests.rs b/dal/writers/requests.rs index 80d0a3fe35519153651aa8b74829ae0ddb8426cb..825a14af3f91f04f5359f3f0b0fc8783ff7d44bc 100644 --- a/dal/writers/requests.rs +++ b/dal/writers/requests.rs @@ -22,7 +22,7 @@ use duniter_crypto::keys::PubKey; use duniter_documents::blockchain::v10::documents::certification::CompactCertificationDocument; use duniter_documents::blockchain::v10::documents::identity::IdentityDocument; use duniter_documents::Blockstamp; -use duniter_wotb::NodeId; +use durs_wot::NodeId; use identity::DALIdentity; use sources::SourceAmount; use std::ops::Deref; @@ -89,9 +89,9 @@ impl BlocksDBsWriteQuery { #[derive(Debug, Clone)] /// Contain a pending write request for wots databases pub enum WotsDBsWriteQuery { - /// Newcomer (wotb_id, blockstamp, current_bc_time, idty_doc, ms_created_block_id) + /// Newcomer (wot_id, blockstamp, current_bc_time, idty_doc, ms_created_block_id) CreateIdentity(NodeId, Blockstamp, u64, Box<IdentityDocument>, BlockId), - /// Revert newcomer event (wotb_id, blockstamp, current_bc_time, idty_doc, ms_created_block_id) + /// Revert newcomer event (wot_id, blockstamp, current_bc_time, idty_doc, ms_created_block_id) RevertCreateIdentity(PubKey), /// Active (pubKey, idty_wot_id, current_bc_time, ms_created_block_id) RenewalIdentity(PubKey, NodeId, u64, BlockId), @@ -124,7 +124,7 @@ impl WotsDBsWriteQuery { ) -> Result<(), DALError> { match *self { WotsDBsWriteQuery::CreateIdentity( - ref wotb_id, + ref wot_id, ref blockstamp, ref current_bc_time, ref idty_doc, @@ -136,7 +136,7 @@ impl WotsDBsWriteQuery { &databases.ms_db, idty_doc.deref(), *ms_created_block_id, - *wotb_id, + *wot_id, *blockstamp, *current_bc_time, )?; diff --git a/wotb/Cargo.toml b/wot/Cargo.toml similarity index 82% rename from wotb/Cargo.toml rename to wot/Cargo.toml index 803afed1bb96dd5000fcaee3b3fe221e137c8333..900fd3fc39e9ece2ef7de8e32716cdce8c9224cf 100644 --- a/wotb/Cargo.toml +++ b/wot/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "duniter-wotb" -version = "0.8.0-a0.7" +name = "durs-wot" +version = "0.8.0-a0.8" authors = ["nanocryk <nanocryk@duniter.org>", "elois <elois@duniter.org>"] description = "Makes Web of Trust computations for the Duniter project." repository = "https://git.duniter.org/nodes/rust/duniter-rs" readme = "README.md" -keywords = ["duniter", "wot", "wotb", "web", "trust"] +keywords = ["duniter", "wot", "wot", "web", "trust"] license = "AGPL-3.0" [lib] diff --git a/wot/README.md b/wot/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3092a7fbaf898259f142ef8163e7d65b0f48509c --- /dev/null +++ b/wot/README.md @@ -0,0 +1,10 @@ +# wot + +`wot` is a crate making "Web of Trust" computations for +the [Duniter] project. + +[Duniter]: https://duniter.org/en/ + +## How to use it + +You can add `durs-wot` as a `cargo` dependency in your Rust project. \ No newline at end of file diff --git a/wotb/data/mod.rs b/wot/data/mod.rs similarity index 100% rename from wotb/data/mod.rs rename to wot/data/mod.rs diff --git a/wotb/data/rusty.rs b/wot/data/rusty.rs similarity index 100% rename from wotb/data/rusty.rs rename to wot/data/rusty.rs diff --git a/wotb/lib.rs b/wot/lib.rs similarity index 98% rename from wotb/lib.rs rename to wot/lib.rs index a7a0c4f8713fe489cca13fa3a6638d597b040c37..de3734d8be3d881faedd273654d1bdca86b52737 100644 --- a/wotb/lib.rs +++ b/wot/lib.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -//! `wotb` is a crate making "Web of Trust" computations for +//! `wot` is a crate making "Web of Trust" computations for //! the [Duniter] project. //! //! [Duniter]: https://duniter.org/ @@ -22,9 +22,9 @@ //! //! It also contains an "legacy" implementation translated from the original C++ code. //! -//! Web of Trust tests are translated from [duniter/wotb Javascript test][js-tests]. +//! Web of Trust tests are translated from [duniter/wot Javascript test][js-tests]. //! -//! [js-tests]: https://github.com/duniter/wotb/blob/master/wotcpp/webOfTrust.cpp +//! [js-tests]: https://github.com/duniter/wot/blob/master/wotcpp/webOfTrust.cpp #![cfg_attr(feature = "strict", deny(warnings))] #![deny( @@ -60,7 +60,7 @@ mod tests { use operations::file::*; use operations::path::*; - /// Test translated from https://github.com/duniter/wotb/blob/master/tests/test.js + /// Test translated from https://github.com/duniter/wot/blob/master/tests/test.js /// /// Clone and file tests are not included in this generic test and should be done in /// the implementation test. diff --git a/wotb/operations/centrality.rs b/wot/operations/centrality.rs similarity index 100% rename from wotb/operations/centrality.rs rename to wot/operations/centrality.rs diff --git a/wotb/operations/distance.rs b/wot/operations/distance.rs similarity index 100% rename from wotb/operations/distance.rs rename to wot/operations/distance.rs diff --git a/wotb/operations/file.rs b/wot/operations/file.rs similarity index 99% rename from wotb/operations/file.rs rename to wot/operations/file.rs index 515fddaf4cbab33bf1ecae4731b5a277646d3240..785cf784181cbd530679e0aa84fcb4df6d84a8ec 100644 --- a/wotb/operations/file.rs +++ b/wot/operations/file.rs @@ -87,7 +87,7 @@ impl FileFormater for BinaryFileFormater { ) -> Result<(T, Vec<u8>), WotParseError> { let mut wot = T::new(max_links); - let file_size = fs::metadata(path).expect("fail to read wotb file !").len(); + let file_size = fs::metadata(path).expect("fail to read wot file !").len(); let mut file_pointing_to_blockstamp_size: Vec<u8> = vec![0; file_size as usize]; match File::open(path) { Ok(mut file) => { diff --git a/wotb/operations/mod.rs b/wot/operations/mod.rs similarity index 100% rename from wotb/operations/mod.rs rename to wot/operations/mod.rs diff --git a/wotb/operations/path.rs b/wot/operations/path.rs similarity index 100% rename from wotb/operations/path.rs rename to wot/operations/path.rs diff --git a/wotb/tests/g1_genesis.bin b/wot/tests/g1_genesis.bin similarity index 100% rename from wotb/tests/g1_genesis.bin rename to wot/tests/g1_genesis.bin diff --git a/wotb/README.md b/wotb/README.md deleted file mode 100644 index 32266674b05e3aa88c51a4c7a199646e2c7428db..0000000000000000000000000000000000000000 --- a/wotb/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# wotb - -`wotb` is a crate making "Web of Trust" computations for -the [Duniter] project. - -[Duniter]: https://duniter.org/en/ - -## How to use it - -You can add `duniter-wotb` as a `cargo` dependency in your Rust project. \ No newline at end of file diff --git a/ws2p-v1-legacy/Cargo.toml b/ws2p-v1-legacy/Cargo.toml index 3df5308efa61a620d54d3d7a78dba9913c5e322f..63e77f2cbfb42055b5a4e3d2fe57c5d5d041c172 100644 --- a/ws2p-v1-legacy/Cargo.toml +++ b/ws2p-v1-legacy/Cargo.toml @@ -17,7 +17,7 @@ duniter-documents = { path = "../documents" } duniter-message = { path = "../message" } duniter-module = { path = "../module" } duniter-network = { path = "../network" } -duniter-wotb = { path = "../wotb" } +durs-wot = { path = "../wot" } lazy_static = "1.0.*" log = "0.4.*" rand = "0.4.*"