-
Notifications
You must be signed in to change notification settings - Fork 25
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
[issue] Can't share struct Wallet
by using Lazy
#18
Comments
I suppose this is a different {approach|issue} from RGB-WG/rgb-node#222 . |
@monaka running both The error doesn't seem strictly related to rgb-lib, looking to the code I think there are a few things that need to be fixed. First, the example uses a lot of unnecessary complexity, making it harder to locate exactly what's the issue. Moreover I don't understand why you are also saving I've pushed here a commit that simplifies the example, showing that it's possible to share the rgb-lib |
Surely, my code doesn't have the In fact, tests don't use the main function.
|
@monaka I was just reporting the typo (that you actually made again, you are saying |
This is simple. Users may want to store mnemonic on the front-end side.
Yes. Once the Wallet was instantiated, we can use In other words, the back-end should be changed to its states as follows:
|
@monaka The flow you describe is possible and also instantiating and sharing the wallet with a combination of |
How to reproduce
Expected
Finishes builds.
Actually
Failed to errors.
Addtional
cargo build
is built with no error.Logs after running `cargo build --all-features`.
$ cargo test --all-features Compiling wallet-share v0.1.0 (/home/monaka/diamondhands-rdb/rgb-lib-sample/wallet-share) error[E0277]: `RefCell` cannot be shared between threads safely --> src/main.rs:31:26 | 31 | static WALLET_STATE: Lazy>> = Lazy::new(|| Arc::new(RwLock::new(WalletState::new()))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely | = help: within `WalletState`, the trait `Sync` is not implemented for `RefCell` = note: required because it appears within the type `bdk::wallet::Wallet` = note: required because it appears within the type `rgb_lib::Wallet` = note: required because it appears within the type `Option` note: required because it appears within the type `WalletState` --> src/main.rs:9:12 | 9 | pub struct WalletState { | ^^^^^^^^^^^ = note: required for `std::sync::RwLock` to implement `Sync` = note: 2 redundant requirements hidden = note: required for `once_cell::imp::OnceCell>>` to implement `Sync` = note: required because it appears within the type `once_cell::sync::OnceCell>>` = note: required for `once_cell::sync::Lazy>>` to implement `Sync` = note: shared static variables must have a type that implements `Sync`error[E0277]:
*mut c_void
cannot be shared between threads safely--> src/main.rs:31:26
|
31 | static WALLET_STATE: Lazy<Arc<RwLock>> = Lazy::new(|| Arc::new(RwLock::new(WalletState::new())));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*mut c_void
cannot be shared between threads safely|
= help: within
(rgb_rpc::client::RpcBus, microservices::esb::controller::Endpoint<rgb_rpc::service_id::ServiceId>)
, the traitSync
is not implemented for*mut c_void
= note: required because it appears within the type
zmq2::Socket
= note: required because it appears within the type
internet2::transport::zeromq::WrappedSocket
= note: required because it appears within the type
internet2::transport::zeromq::Connection
= note: required because it appears within the type
internet2::session::session::Session<internet2::session::transcoders::PlainTranscoder, internet2::transport::zeromq::Connection>
= note: required because it appears within the type
microservices::esb::controller::Endpoint<rgb_rpc::service_id::ServiceId>
= note: required because it appears within the type
(rgb_rpc::client::RpcBus, microservices::esb::controller::Endpoint<rgb_rpc::service_id::ServiceId>)
= note: required for
hashbrown::raw::RawTable<(rgb_rpc::client::RpcBus, microservices::esb::controller::Endpoint<rgb_rpc::service_id::ServiceId>)>
to implementSync
= note: required because it appears within the type
hashbrown::map::HashMap<rgb_rpc::client::RpcBus, microservices::esb::controller::Endpoint<rgb_rpc::service_id::ServiceId>, RandomState>
= note: required because it appears within the type
HashMap<rgb_rpc::client::RpcBus, microservices::esb::controller::Endpoint<rgb_rpc::service_id::ServiceId>>
= note: required because it appears within the type
microservices::esb::controller::EndpointList<rgb_rpc::client::RpcBus>
= note: required because it appears within the type
microservices::esb::controller::Controller<rgb_rpc::client::RpcBus, rgb_rpc::messages::BusMsg, rgb_rpc::client::Handler>
= note: required because it appears within the type
rgb_rpc::client::Client
= note: required because it appears within the type
Option<rgb_rpc::client::Client>
= note: required because it appears within the type
rgb_lib::Wallet
= note: required because it appears within the type
Option<rgb_lib::Wallet>
note: required because it appears within the type
WalletState
--> src/main.rs:9:12
|
9 | pub struct WalletState {
| ^^^^^^^^^^^
= note: required for
std::sync::RwLock<WalletState>
to implementSync
= note: 2 redundant requirements hidden
= note: required for
once_cell::imp::OnceCell<std::sync::Arc<std::sync::RwLock<WalletState>>>
to implementSync
= note: required because it appears within the type
once_cell::sync::OnceCell<std::sync::Arc<std::sync::RwLock<WalletState>>>
= note: required for
once_cell::sync::Lazy<std::sync::Arc<std::sync::RwLock<WalletState>>>
to implementSync
= note: shared static variables must have a type that implements
Sync
For more information about this error, try
rustc --explain E0277
.error: could not compile
wallet-share
due to 2 previous errorsrefs #16 (comment)
The text was updated successfully, but these errors were encountered: