Skip to content

Commit e8d79f5

Browse files
committed
feat: small wasm support
1 parent c5ef755 commit e8d79f5

File tree

48 files changed

+693
-325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+693
-325
lines changed

Cargo.lock

Lines changed: 78 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,14 @@ bench-test:
219219

220220
.PHONY: ci
221221
ci: ## Run recipes for CI.
222-
ci: fmt clippy test bench-test check-cargo-metadata check-cargotoml check-whitespaces check-dirty-rpc-doc security-audit check-crates check-licenses
222+
ci: fmt clippy wasm test bench-test check-cargo-metadata check-cargotoml check-whitespaces check-dirty-rpc-doc security-audit check-crates check-licenses
223223
git diff --exit-code Cargo.lock
224224

225+
.PHONY: wasm
226+
wasm:
227+
rustup target add wasm32-unknown-unknown
228+
cd network && cargo c --target wasm32-unknown-unknown
229+
225230
.PHONY: check-cargotoml
226231
check-cargotoml:
227232
./devtools/ci/check-cargotoml.sh

db/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ ckb-app-config = { path = "../util/app-config", version = "= 0.120.0-pre" }
1313
ckb-logger = { path = "../util/logger", version = "= 0.120.0-pre" }
1414
ckb-error = { path = "../error", version = "= 0.120.0-pre" }
1515
libc = "0.2"
16-
rocksdb = { package = "ckb-rocksdb", version ="=0.21.1", features = ["snappy", "lz4"], default-features = false }
16+
rocksdb = { package = "ckb-rocksdb", version = "=0.21.1", features = [
17+
"snappy",
18+
"lz4",
19+
], default-features = false }
1720
ckb-db-schema = { path = "../db-schema", version = "= 0.120.0-pre" }
1821

22+
1923
[dev-dependencies]
2024
tempfile.workspace = true
2125

network/Cargo.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,33 @@ bs58 = { version = "0.5.0", optional = true }
2525
sentry = { version = "0.34.0", optional = true }
2626
faster-hex = { version = "0.6", optional = true }
2727
ckb-hash = { path = "../util/hash", version = "= 0.120.0-pre" }
28-
secp256k1 = { version = "0.29", features = ["recovery"], optional = true }
28+
secp256k1 = { version = "0.30", features = ["recovery"], optional = true }
2929
trust-dns-resolver = { version = "0.23", optional = true }
3030
snap = "1"
3131
ckb-types = { path = "../util/types", version = "= 0.120.0-pre" }
3232
ipnetwork = "0.20"
3333
serde_json = "1.0"
3434
bloom-filters = "0.1"
3535
ckb-spawn = { path = "../util/spawn", version = "= 0.120.0-pre" }
36-
socket2 = "0.5"
3736
bitflags = "1.0"
37+
p2p = { version = "0.6.2", package = "tentacle", default-features = false }
3838

39-
p2p = { version = "0.6.1", package = "tentacle", features = [
39+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
40+
p2p = { version = "0.6.2", package = "tentacle", default-features = false, features = [
4041
"upnp",
4142
"parking_lot",
4243
"openssl-vendored",
44+
"tokio-runtime",
45+
"tokio-timer",
46+
"ws",
4347
] }
48+
socket2 = "0.5"
49+
50+
[target.'cfg(target_family = "wasm")'.dependencies]
51+
p2p = { version = "0.6.2", package = "tentacle", default-features = false, features = [
52+
"wasm-timer",
53+
] }
54+
4455

4556
[features]
4657
with_sentry = ["sentry"]

network/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ pub use crate::{
3232
peer_registry::PeerRegistry,
3333
peer_store::Score,
3434
protocols::{
35-
identify::Flags, support_protocols::SupportProtocols, CKBProtocol, CKBProtocolContext,
36-
CKBProtocolHandler, PeerIndex,
35+
identify::Flags, support_protocols::SupportProtocols, BoxedCKBProtocolContext, CKBProtocol,
36+
CKBProtocolContext, CKBProtocolHandler, PeerIndex,
3737
},
3838
};
3939
pub use p2p::{
4040
async_trait,
4141
builder::ServiceBuilder,
42-
bytes, multiaddr,
42+
bytes, multiaddr, runtime,
4343
secio::{PeerId, PublicKey},
4444
service::{ServiceControl, SessionType, TargetProtocol, TargetSession},
4545
traits::ServiceProtocol,

0 commit comments

Comments
 (0)