-
Notifications
You must be signed in to change notification settings - Fork 2.2k
ProgramClient : add Send and Sync maker trait #6510
Conversation
Sorry, I'm a bit confused about how this is supposed to help. A marker on the trait here shouldn't make a difference, since you should be able to add
Can you give a code example that's failing to build because of how the trait is currently implemented? That might help figure out the right solution |
ok here is my code
and here is error The system prompt indicates that ProgramClient has not implemented the Sync trait, which prevents it from being sent between multiple threads. |
This seems to be using |
Precisely, my raydiumClient encapsulates a simple function. In this function, I instantiate ProgramClient to interact with Token. In the context of Tokio multithreading, it's not possible to assign ProgramClient to Token. here is my function
here is cargo check error
|
I noticed that someone else also raised the same issue, that is, Token cannot be sent or synchronized, thus Token cannot be used in a multithreaded environment. Therefore, I submitted this pull request. |
the same error : #6478 |
Thanks for giving an example! I tried it out, but unfortunately this takes a lot more to fix because we also need to be sure that the I got a branch at https://github.com/joncinque/solana-program-library/tree/tkclientsend which gets token-client to compile and all the token-2022 tests to pass, but there's more work needed to fixup all uses of it. Would you be up to fixing it for the whole repo? |
First of all, I am more than happy to do this and contribute to the open source community. I am honored to have the opportunity. However, I have only been learning Rust development for a year, so facing such a massive project, I feel a bit intimidated. But I will do my best to give it a try. |
No worries at all. If you're up to it, I'd say give it a shot, and if you get stuck, let me know! I can always take over. I've created draft pull request #6523, you should be able to develop on that branch, or you can create your own PR from it |
I will give it a try. |
I plan to use ProgramClient to build a service, which is a multi-threaded service. However, the current design prevents ProgramClient from being sent or shared directly between multiple threads. Therefore, I have added these two markers to the trait.