Skip to content
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

chore(eth-websocket): remove some unnecessary wrappers #2291

Merged
merged 5 commits into from
Dec 26, 2024
Merged

Conversation

mariocynicys
Copy link
Collaborator

Removes some Arcs and Mutexs that aren't needed (because of another wrapping Arc or the object being already thread-safe).

@mariocynicys mariocynicys force-pushed the share-web3 branch 2 times, most recently from 22ff5c1 to a394c6a Compare December 13, 2024 10:46
Comment on lines 89 to 92
controller_channel: ControllerChannel {
tx: Arc::new(AsyncMutex::new(req_tx)),
tx: req_tx,
rx: Arc::new(AsyncMutex::new(req_rx)),
}
.into(),
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rx: AsyncMutex::new(req_rx)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that arc was indeed the unnecessary one, thanks :)
8ae149b

mm2src/coins/eth/web3_transport/websocket_transport.rs Outdated Show resolved Hide resolved
mm2src/coins/eth/web3_transport/websocket_transport.rs Outdated Show resolved Hide resolved
Comment on lines 49 to 53
controller_channel: Arc<ControllerChannel>,
controller_channel: ControllerChannel,
connection_guard: Arc<AsyncMutex<()>>,
}

#[derive(Debug)]
#[derive(Clone, Debug)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why replacing Arc with Clone?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both tx & rx inside were Arced which made me think we extract/clone them out of ContollerChannel so wrapping with a bigger arc is just a complex optimization.
this doesn't seem the case though (tx already clonable, rx was never cloned out in the first place).
8ae149b

@onur-ozkan onur-ozkan merged commit ae5c6c1 into dev Dec 26, 2024
20 of 23 checks passed
@onur-ozkan onur-ozkan deleted the share-web3 branch December 26, 2024 10:29
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request Jan 17, 2025
* dev: (35 commits)
  fix(crypto): allow non bip39 mnemonics storage (KomodoPlatform#2312)
  fix(legacy_swap): check for existing maker/taker payment before timeout (KomodoPlatform#2283)
  feat(tendermint): validators RPC (KomodoPlatform#2310)
  chore(CI): validate Cargo lock file (KomodoPlatform#2309)
  test(P2P): add test for peer time sync validation (KomodoPlatform#2304)
  fix mm2_p2p dev build (KomodoPlatform#2311)
  update Cargo.lock (KomodoPlatform#2308)
  chore(CI): unlock wasm-pack version (KomodoPlatform#2307)
  add `wasm` feature on WASM for timed-map (KomodoPlatform#2306)
  replace broken rpc link (KomodoPlatform#2305)
  chore(eth-websocket): remove some unnecessary wrappers (KomodoPlatform#2291)
  improvement(CI): switch to proper rust caching (KomodoPlatform#2303)
  fix(wasm): add test-ext-api feature to mm2_main and mm2_bin_lib tomls (KomodoPlatform#2295)
  chore(ci): Update docker build for wasm (KomodoPlatform#2294)
  chore(p2p): follow-up nits (KomodoPlatform#2302)
  feat(p2p): ensure time synchronization in the network (KomodoPlatform#2255)
  bump libp2p (KomodoPlatform#2296)
  chore(adex-cli): use "Komodo DeFi Framework" name in adex_cli  (KomodoPlatform#2290)
  chore(ctx): replace gstuff constructible with oncelock (KomodoPlatform#2267)
  don't rely on core (KomodoPlatform#2289)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants