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

Commit

Permalink
Merge pull request #1812 from holochain/hcmutex-gets-own-crate
Browse files Browse the repository at this point in the history
core_types::sync gets its own crate
  • Loading branch information
maackle committed Oct 31, 2019
2 parents b94b0ed + 4812b64 commit a5ad16c
Show file tree
Hide file tree
Showing 47 changed files with 200 additions and 125 deletions.
71 changes: 52 additions & 19 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"crates/dpki",
"crates/hdk_v2",
"crates/hdk",
"crates/locksmith",
"crates/net",
"crates/sim1h",
"crates/sim2h",
Expand Down
1 change: 1 addition & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ holochain_core = { version = "=0.0.35-alpha7", path = "../core" }
holochain_common = { version = "=0.0.35-alpha7", path = "../common" }
holochain_conductor_lib = { version = "=0.0.35-alpha7", path = "../conductor_lib" }
holochain_dpki = { version = "=0.0.35-alpha7", path = "../dpki" }
holochain_locksmith = { path = "../locksmith" }
lib3h_sodium = "=0.0.21"
holochain_json_api = "=0.0.17"
holochain_persistence_api = "=0.0.10"
Expand Down
3 changes: 2 additions & 1 deletion crates/cli/src/cli/chain_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use holochain_core::agent::{
chain_store::ChainStore,
state::{AgentState, AgentStateSnapshot},
};
use holochain_core_types::{chain_header::ChainHeader, entry::Entry, sync::HcRwLock as RwLock};
use holochain_core_types::{chain_header::ChainHeader, entry::Entry};
use holochain_locksmith::RwLock;
use holochain_persistence_api::cas::content::Address;
use holochain_persistence_file::cas::file::FilesystemStorage;
use std::{convert::TryFrom, fs, path::PathBuf};
Expand Down
1 change: 1 addition & 0 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern crate holochain_conductor_lib;
extern crate holochain_core;
extern crate holochain_core_types;
extern crate holochain_json_api;
extern crate holochain_locksmith;
extern crate holochain_persistence_api;
extern crate holochain_persistence_file;
extern crate lib3h_sodium;
Expand Down
1 change: 1 addition & 0 deletions crates/conductor_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ edition = "2018"
[dependencies]
holochain_core_types = { version = "=0.0.35-alpha7", path = "../core_types" }
holochain_wasm_utils = { version = "=0.0.35-alpha7", path = "../wasm_utils" }
holochain_locksmith = { path = "../locksmith" }
jsonrpc-core = "=14.0.1"
jsonrpc-lite = "=0.5.0"
serde = { version = "=1.0.89", features = ["rc"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/conductor_api/src/conductor_api.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use holochain_core_types::{error::HolochainError, sync::HcRwLock as RwLock};
use holochain_core_types::error::HolochainError;
use holochain_locksmith::RwLock;
use holochain_wasm_utils::api_serialization::crypto::CryptoMethod;
use jsonrpc_core::IoHandler;
use jsonrpc_lite::JsonRpc;
Expand Down
1 change: 1 addition & 0 deletions crates/conductor_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ authors = ["Holochain Core Dev Team <devcore@holochain.org>"]
[dependencies]
holochain_core = { version = "=0.0.35-alpha7", path = "../core" }
holochain_core_types = { version = "=0.0.35-alpha7", path = "../core_types" }
holochain_locksmith = { path = "../locksmith" }
holochain_json_derive = "=0.0.17"
holochain_json_api = "=0.0.17"
holochain_persistence_api = "=0.0.10"
Expand Down
4 changes: 2 additions & 2 deletions crates/conductor_lib/src/conductor/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
dpki_instance::DpkiInstance,
keystore::{Keystore, PRIMARY_KEYBUNDLE_ID},
};
use holochain_core_types::{error::HolochainError, sync::HcRwLock as RwLock};

use holochain_core_types::error::HolochainError;
use holochain_locksmith::RwLock;
use holochain_persistence_api::{cas::content::AddressableContent, hash::HashString};

use json_patch;
Expand Down
2 changes: 1 addition & 1 deletion crates/conductor_lib/src/conductor/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use holochain_core_types::{
agent::AgentId,
dna::Dna,
error::{HcResult, HolochainError},
sync::{HcMutex as Mutex, HcRwLock as RwLock},
};
use holochain_locksmith::{Mutex, RwLock};
use key_loaders::test_keystore;

use holochain_json_api::json::JsonString;
Expand Down
45 changes: 23 additions & 22 deletions crates/conductor_lib/src/conductor/passphrase_manager.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crossbeam_channel::{unbounded, Sender};
use holochain_core_types::{error::HolochainError, sync::HcMutex as Mutex};
use holochain_core_types::error::HolochainError;
use holochain_locksmith::Mutex;
use lib3h_sodium::secbuf::SecBuf;
#[cfg(unix)]
use log::Level;
Expand Down Expand Up @@ -179,28 +180,28 @@ impl PassphraseService for PassphraseServiceUnixSocket {

// Request and read passphrase from socket
let mut passphrase_string = {
let mut stream_option = self.stream.lock().expect(
self.stream.lock().expect(
"Could not lock mutex holding unix domain socket connection for passphrase service",
);
let listen_result = stream_option.as_mut()
.expect("This option must be some at this point since we would be in above while loop otherwise.");
let stream = listen_result
.as_mut()
.expect("Error accepting unix socket connection for passphrase service");

log_debug!("Sending passphrase request via unix socket...");
stream
.get_mut()
.write_all(b"request_passphrase")
.expect("Could not write to passphrase socket");
log_debug!("Passphrase request sent.");
let mut passphrase_string = String::new();
log_debug!("Reading passphrase from socket...");
stream
.read_line(&mut passphrase_string)
.expect("Could not read from passphrase socket");
log_debug!("Got passphrase. All fine.");
passphrase_string
)
.as_mut().as_mut()
.ok_or_else(|| HolochainError::ErrorGeneric("This option can't possibly be None".into()))
.and_then(|result| result.as_mut().map(|stream| {
log_debug!("Sending passphrase request via unix socket...");
stream
.get_mut()
.write_all(b"request_passphrase")
.expect("Could not write to passphrase socket");
log_debug!("Passphrase request sent.");
let mut passphrase_string = String::new();
log_debug!("Reading passphrase from socket...");
stream
.read_line(&mut passphrase_string)
.expect("Could not read from passphrase socket");
log_debug!("Got passphrase. All fine.");
passphrase_string
})
.map_err(|_e| HolochainError::ErrorGeneric("Error accepting unix socket connection for passphrase service".into()))
)?
};

// Move passphrase in secure memory
Expand Down
5 changes: 2 additions & 3 deletions crates/conductor_lib/src/context_builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use holochain_core::{context::Context, persister::SimplePersister, signal::SignalSender};
use holochain_core_types::{
agent::AgentId, eav::Attribute, error::HolochainError, sync::HcRwLock as RwLock,
};
use holochain_core_types::{agent::AgentId, eav::Attribute, error::HolochainError};
use holochain_locksmith::RwLock;
use holochain_net::p2p_config::P2pConfig;
use holochain_persistence_api::{
cas::storage::ContentAddressableStorage, eav::EntityAttributeValueStorage,
Expand Down
3 changes: 2 additions & 1 deletion crates/conductor_lib/src/holochain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@ mod tests {
nucleus::actions::call_zome_function::make_cap_request_for_call,
signal::{signal_channel, SignalReceiver},
};
use holochain_core_types::{dna::capabilities::CapabilityRequest, sync::HcMutex as Mutex};
use holochain_core_types::dna::capabilities::CapabilityRequest;
use holochain_json_api::json::RawString;
use holochain_locksmith::Mutex;
use holochain_persistence_api::cas::content::{Address, AddressableContent};
use holochain_wasm_utils::wasm_target_dir;
use std::{path::PathBuf, sync::Arc};
Expand Down
6 changes: 2 additions & 4 deletions crates/conductor_lib/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ use crossbeam_channel::Receiver;
use holochain_core::nucleus::actions::call_zome_function::make_cap_request_for_call;

use holochain_core_types::{
agent::AgentId,
dna::capabilities::CapabilityRequest,
signature::Provenance,
sync::{HcMutex as Mutex, HcRwLock as RwLock},
agent::AgentId, dna::capabilities::CapabilityRequest, signature::Provenance,
};
use holochain_dpki::key_bundle::KeyBundle;
use holochain_json_api::json::JsonString;
use holochain_locksmith::{Mutex, RwLock};
use holochain_persistence_api::cas::content::Address;
use lib3h_sodium::secbuf::SecBuf;
use Holochain;
Expand Down
3 changes: 2 additions & 1 deletion crates/conductor_lib/src/key_loaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use crate::{
keystore::{Keystore, Secret, PRIMARY_KEYBUNDLE_ID},
};
use conductor::passphrase_manager::{PassphraseManager, PassphraseServiceMock};
use holochain_core_types::{error::HolochainError, sync::HcMutex as Mutex};
use holochain_core_types::error::HolochainError;
use holochain_dpki::{password_encryption::PwHashConfig, SEED_SIZE};
use holochain_locksmith::Mutex;
use keystore::test_hash_config;
use lib3h_sodium::{hash::sha256, secbuf::SecBuf};
use std::{path::PathBuf, sync::Arc};
Expand Down
2 changes: 1 addition & 1 deletion crates/conductor_lib/src/keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use holochain_core_types::{
agent::Base32,
error::{HcResult, HolochainError},
signature::Signature,
sync::HcMutex as Mutex,
};
use holochain_dpki::{
key_blob::{BlobType, Blobbable, KeyBlob},
Expand All @@ -15,6 +14,7 @@ use holochain_dpki::{
},
SEED_SIZE,
};
use holochain_locksmith::Mutex;

use lib3h_sodium::{
pwhash::{ALG_ARGON2ID13, MEMLIMIT_INTERACTIVE, OPSLIMIT_INTERACTIVE},
Expand Down
1 change: 1 addition & 0 deletions crates/conductor_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ extern crate holochain_core_types;
extern crate holochain_json_derive;
extern crate holochain_dpki;
extern crate holochain_json_api;
extern crate holochain_locksmith;
extern crate holochain_net;
extern crate holochain_persistence_api;
extern crate holochain_persistence_file;
Expand Down
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ holochain_persistence_file = "=0.0.10"
holochain_persistence_mem = "=0.0.10"
holochain_core_types = { version = "=0.0.35-alpha7", path = "../core_types" }
holochain_dpki = { version = "=0.0.35-alpha7", path = "../dpki" }
holochain_locksmith = { path = "../locksmith" }
log = "=0.4.8"
holochain_logging = "=0.0.4"
boolinator = "=2.4.0"
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/agent/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use holochain_core_types::{
chain_header::ChainHeader,
entry::entry_type::EntryType,
error::RibosomeErrorCode::{self, *},
sync::HcRwLock as RwLock,
};
use holochain_locksmith::RwLock;
use holochain_persistence_api::cas::{
content::{Address, AddressableContent},
storage::ContentAddressableStorage,
Expand Down Expand Up @@ -305,10 +305,10 @@ pub mod tests {
entry_type::{test_entry_type_b, AppEntryType},
test_entry, test_entry_b, test_entry_c, Entry,
},
sync::HcRwLock as RwLock,
time::test_iso_8601,
};
use holochain_json_api::json::{JsonString, RawString};
use holochain_locksmith::RwLock;
use holochain_persistence_api::cas::content::AddressableContent;
use holochain_persistence_file::cas::file::FilesystemStorage;
use tempfile;
Expand Down
8 changes: 3 additions & 5 deletions crates/core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ use holochain_core_types::{
Entry,
},
error::{HcResult, HolochainError},
sync::{
HcMutex as Mutex, HcMutexGuard as MutexGuard, HcRwLock as RwLock,
HcRwLockReadGuard as RwLockReadGuard,
},
};
use holochain_locksmith::{Mutex, MutexGuard, RwLock, RwLockReadGuard};
use holochain_net::{p2p_config::P2pConfig, p2p_network::P2pNetwork};
use holochain_persistence_api::{
cas::{
Expand Down Expand Up @@ -394,7 +391,8 @@ pub mod tests {
use self::tempfile::tempdir;
use super::*;
use crate::persister::SimplePersister;
use holochain_core_types::{agent::AgentId, sync::HcRwLock as RwLock};
use holochain_core_types::agent::AgentId;
use holochain_locksmith::RwLock;
use holochain_persistence_file::{cas::file::FilesystemStorage, eav::file::EavFileStorage};
use std::sync::Arc;
use tempfile;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/dht/dht_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use holochain_core_types::{
eav::{Attribute, EaviQuery, EntityAttributeValueIndex},
entry::Entry,
error::HolochainError,
sync::HcRwLock as RwLock,
};
use holochain_json_api::{error::JsonError, json::JsonString};
use holochain_locksmith::RwLock;
use holochain_persistence_api::{
cas::{
content::{Address, AddressableContent},
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use crossbeam_channel::{unbounded, Receiver, Sender};
use holochain_core_types::{
dna::Dna,
error::{HcResult, HolochainError},
sync::{HcRwLock as RwLock, HcRwLockReadGuard as RwLockReadGuard},
ugly::lax_send_sync,
};
use holochain_locksmith::{RwLock, RwLockReadGuard};
#[cfg(test)]
use holochain_persistence_api::cas::content::Address;
use snowflake::ProcessUniqueId;
Expand Down Expand Up @@ -396,8 +396,8 @@ pub mod tests {
chain_header::test_chain_header,
dna::{zome::Zome, Dna},
entry::{entry_type::EntryType, test_entry},
sync::{HcMutex as Mutex, HcRwLock as RwLock},
};
use holochain_locksmith::{Mutex, RwLock};
use holochain_persistence_api::cas::content::AddressableContent;
use holochain_persistence_file::{cas::file::FilesystemStorage, eav::file::EavFileStorage};
use tempfile;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! gets emitted globaly from the conductor.
use chrono::Local;
use crossbeam_channel;
use holochain_core_types::sync::HcMutex as Mutex;
use holochain_locksmith::Mutex;
use std::sync::Arc;

/// trait that defines the logging functionality that holochain_core requires
Expand Down
3 changes: 2 additions & 1 deletion crates/core/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ macro_rules! log_error {
#[test]
fn context_log_macro_test() {
use crate::{context::Context, persister::SimplePersister};
use holochain_core_types::{agent::AgentId, sync::HcRwLock as RwLock};
use holochain_core_types::agent::AgentId;
use holochain_locksmith::RwLock;
use holochain_net::p2p_config::P2pConfig;
use holochain_persistence_file::{cas::file::FilesystemStorage, eav::file::EavFileStorage};
use std::sync::Arc;
Expand Down
7 changes: 2 additions & 5 deletions crates/core/src/network/actions/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ use crate::{
};
use crossbeam_channel::Sender;
use futures::{future::Future, task::Poll};

use holochain_core_types::{
error::{HcResult, HolochainError},
sync::HcRwLock as RwLock,
};
use holochain_core_types::error::{HcResult, HolochainError};
use holochain_locksmith::RwLock;

use crate::state::StateWrapper;
use std::{pin::Pin, sync::Arc};
Expand Down
3 changes: 2 additions & 1 deletion crates/core/src/network/reducers/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ pub mod test {
persister::SimplePersister,
state::{test_store, StateWrapper},
};
use holochain_core_types::{agent::AgentId, sync::HcRwLock as RwLock};
use holochain_core_types::agent::AgentId;
use holochain_locksmith::RwLock;
use holochain_net::{connection::net_connection::NetHandler, p2p_config::P2pConfig};
use holochain_persistence_api::cas::content::{Address, AddressableContent};
use holochain_persistence_file::{cas::file::FilesystemStorage, eav::file::EavFileStorage};
Expand Down
4 changes: 1 addition & 3 deletions crates/core/src/nucleus/actions/get_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ use holochain_core_types::{
eav::{Attribute, EaviQuery, EntityAttributeValueIndex},
entry::{Entry, EntryWithMeta},
error::HolochainError,
sync::HcRwLock as RwLock,
};

use holochain_locksmith::RwLock;
use holochain_persistence_api::{
cas::{
content::{Address, AddressableContent},
storage::ContentAddressableStorage,
},
eav::IndexFilter,
};

use std::{collections::BTreeSet, str::FromStr, sync::Arc};

pub(crate) fn get_entry_from_cas(
Expand Down
3 changes: 2 additions & 1 deletion crates/core/src/persister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::{
nucleus::state::{NucleusStateSnapshot, NUCLEUS_SNAPSHOT_ADDRESS},
state::State,
};
use holochain_core_types::{error::HolochainError, sync::HcRwLock as RwLock};
use holochain_core_types::error::HolochainError;
use holochain_locksmith::RwLock;

use holochain_persistence_api::cas::{
content::{Address, AddressableContent, Content},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use holochain_core_types::{
eav::{Attribute, EaviQuery},
entry::{entry_type::EntryType, Entry},
error::{HcResult, HolochainError},
sync::HcRwLock as RwLock,
};
use holochain_locksmith::RwLock;
use holochain_persistence_api::{
cas::{
content::{Address, AddressableContent},
Expand Down
1 change: 1 addition & 0 deletions crates/core_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ objekt= "=0.1.2"
holochain_persistence_api = "=0.0.10"
holochain_json_derive = "=0.0.17"
holochain_json_api = "=0.0.17"
holochain_locksmith = { path = "../locksmith" }
uuid = { version = "=0.7.1", features = ["v4"] }
regex = "=1.1.2"
shrinkwraprs = "=0.2.1"
Expand Down

0 comments on commit a5ad16c

Please sign in to comment.