~comcloudway/little_town

34c921cd360a55ed3568314487543942f918ab2f — Jakob Meier 1 year, 8 months ago f2cfeb8
Fixed local multiplayer,
by rewriting p2p library to use gossipsub
instead of floodsub, as it has no message-length restriction
3 files changed, 621 insertions(+), 827 deletions(-)

M Cargo.lock
M Cargo.toml
M src/p2p.rs
M Cargo.lock => Cargo.lock +535 -649
@@ 24,7 24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
dependencies = [
 "cfg-if",
 "cipher 0.3.0",
 "cipher",
 "cpufeatures",
 "opaque-debug",
]


@@ 37,7 37,7 @@ checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6"
dependencies = [
 "aead",
 "aes",
 "cipher 0.3.0",
 "cipher",
 "ctr",
 "ghash",
 "subtle",


@@ 77,9 77,48 @@ checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"

[[package]]
name = "arrayvec"
version = "0.5.2"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"

[[package]]
name = "asn1-rs"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
checksum = "cf6690c370453db30743b373a60ba498fc0d6d83b11f4abfd87a84a075db5dd4"
dependencies = [
 "asn1-rs-derive",
 "asn1-rs-impl",
 "displaydoc",
 "nom",
 "num-traits",
 "rusticata-macros",
 "thiserror",
 "time",
]

[[package]]
name = "asn1-rs-derive"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
 "synstructure",
]

[[package]]
name = "asn1-rs-impl"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "asn1_der"


@@ 113,6 152,18 @@ dependencies = [
]

[[package]]
name = "async-fs"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06"
dependencies = [
 "async-lock",
 "autocfg",
 "blocking",
 "futures-lite",
]

[[package]]
name = "async-global-executor"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 158,6 209,18 @@ dependencies = [
]

[[package]]
name = "async-net"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4051e67316bc7eff608fe723df5d32ed639946adcd69e07df41fd42a7b411f1f"
dependencies = [
 "async-io",
 "autocfg",
 "blocking",
 "futures-lite",
]

[[package]]
name = "async-process"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 196,7 259,7 @@ dependencies = [
 "log",
 "memchr",
 "once_cell",
 "pin-project-lite 0.2.9",
 "pin-project-lite",
 "pin-utils",
 "slab",
 "wasm-bindgen-futures",


@@ 204,9 267,9 @@ dependencies = [

[[package]]
name = "async-std-resolver"
version = "0.21.2"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f2f8a4a203be3325981310ab243a28e6e4ea55b6519bffce05d41ab60e09ad8"
checksum = "6ba50e24d9ee0a8950d3d03fc6d0dd10aa14b5de3b101949b4e160f7fee7c723"
dependencies = [
 "async-std",
 "async-trait",


@@ 244,16 307,7 @@ dependencies = [
 "futures-sink",
 "futures-util",
 "memchr",
 "pin-project-lite 0.2.9",
]

[[package]]
name = "atomic"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b88d82667eca772c4aa12f0f1348b3ae643424c8876448f3f7bd5787032e234c"
dependencies = [
 "autocfg",
 "pin-project-lite",
]

[[package]]


@@ 287,16 341,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"

[[package]]
name = "base-x"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270"

[[package]]
name = "base16ct"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce"

[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"

[[package]]
name = "bimap"
version = "0.6.2"
name = "base64"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc0455254eb5c6964c4545d8bac815e1a1be4f3afe0ae695ea539c12d728d44b"
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"

[[package]]
name = "base64ct"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"

[[package]]
name = "bitflags"


@@ 394,7 466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6"
dependencies = [
 "cfg-if",
 "cipher 0.3.0",
 "cipher",
 "cpufeatures",
 "zeroize",
]


@@ 407,7 479,7 @@ checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5"
dependencies = [
 "aead",
 "chacha20",
 "cipher 0.3.0",
 "cipher",
 "poly1305",
 "zeroize",
]


@@ 422,16 494,6 @@ dependencies = [
]

[[package]]
name = "cipher"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e"
dependencies = [
 "crypto-common",
 "inout",
]

[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 447,6 509,12 @@ dependencies = [
]

[[package]]
name = "const-oid"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913"

[[package]]
name = "core-foundation"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 515,16 583,6 @@ dependencies = [
]

[[package]]
name = "crypto-mac"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab"
dependencies = [
 "generic-array",
 "subtle",
]

[[package]]
name = "ctor"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 540,25 598,14 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea"
dependencies = [
 "cipher 0.3.0",
]

[[package]]
name = "cuckoofilter"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b810a8449931679f64cd7eef1bbd0fa315801b6d5d9cdc1ace2804d6529eee18"
dependencies = [
 "byteorder",
 "fnv",
 "rand 0.7.3",
 "cipher",
]

[[package]]
name = "curve25519-dalek"
version = "3.2.1"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0"
checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61"
dependencies = [
 "byteorder",
 "digest 0.9.0",


@@ 603,6 650,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb"

[[package]]
name = "data-encoding-macro"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca"
dependencies = [
 "data-encoding",
 "data-encoding-macro-internal",
]

[[package]]
name = "data-encoding-macro-internal"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db"
dependencies = [
 "data-encoding",
 "syn",
]

[[package]]
name = "der"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de"
dependencies = [
 "const-oid",
 "zeroize",
]

[[package]]
name = "der-parser"
version = "8.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42d4bc9b0db0a0df9ae64634ac5bdefb7afcb534e182275ca0beadbe486701c1"
dependencies = [
 "asn1-rs",
 "displaydoc",
 "nom",
 "num-bigint",
 "num-traits",
 "rusticata-macros",
]

[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 623,13 714,14 @@ dependencies = [
]

[[package]]
name = "dns-parser"
version = "0.8.0"
name = "displaydoc"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea"
checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886"
dependencies = [
 "byteorder",
 "quick-error",
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]


@@ 653,7 745,7 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d"
dependencies = [
 "curve25519-dalek 3.2.1",
 "curve25519-dalek 3.2.0",
 "ed25519",
 "rand 0.7.3",
 "serde",


@@ 669,11 761,11 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"

[[package]]
name = "enum-as-inner"
version = "0.4.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73"
checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116"
dependencies = [
 "heck 0.4.1",
 "heck",
 "proc-macro2",
 "quote",
 "syn",


@@ 734,7 826,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
dependencies = [
 "crc32fast",
 "libz-sys",
 "miniz_oxide",
]



@@ 823,7 914,7 @@ dependencies = [
 "futures-io",
 "memchr",
 "parking",
 "pin-project-lite 0.2.9",
 "pin-project-lite",
 "waker-fn",
]



@@ 880,7 971,7 @@ dependencies = [
 "futures-sink",
 "futures-task",
 "memchr",
 "pin-project-lite 0.2.9",
 "pin-project-lite",
 "pin-utils",
 "slab",
]


@@ 913,10 1004,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
dependencies = [
 "cfg-if",
 "js-sys",
 "libc",
 "wasi 0.11.0+wasi-snapshot-preview1",
 "wasm-bindgen",
]

[[package]]


@@ 961,18 1050,6 @@ name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
 "ahash",
]

[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
 "unicode-segmentation",
]

[[package]]
name = "heck"


@@ 1002,27 1079,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f"

[[package]]
name = "hmac"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840"
dependencies = [
 "crypto-mac",
 "digest 0.9.0",
]

[[package]]
name = "hmac-drbg"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1"
dependencies = [
 "digest 0.9.0",
 "generic-array",
 "hmac",
]

[[package]]
name = "hostname"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1040,12 1096,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d13cdbd5dbb29f9c88095bbdc2590c9cba0d0a1269b983fef6b2cdd7e9f4db1"

[[package]]
name = "httparse"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"

[[package]]
name = "idna"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1078,9 1128,9 @@ dependencies = [

[[package]]
name = "if-watch"
version = "1.1.1"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "015a7df1eb6dda30df37f34b63ada9b7b352984b0e84de2a20ed526345000791"
checksum = "ba7abdbb86e485125dad06c2691e1e393bf3b08c7b743b43aa162a00fd39062e"
dependencies = [
 "async-io",
 "core-foundation",


@@ 1090,6 1140,7 @@ dependencies = [
 "ipnet",
 "log",
 "rtnetlink",
 "smol",
 "system-configuration",
 "windows",
]


@@ 1119,15 1170,6 @@ dependencies = [
]

[[package]]
name = "inout"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
dependencies = [
 "generic-array",
]

[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1189,15 1231,6 @@ dependencies = [
]

[[package]]
name = "keccak"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768"
dependencies = [
 "cpufeatures",
]

[[package]]
name = "kv-log-macro"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1237,73 1270,38 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"

[[package]]
name = "libp2p"
version = "0.44.0"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "475ce2ac4a9727e53a519f6ee05b38abfcba8f0d39c4d24f103d184e36fd5b0f"
checksum = "3eb49f950659c645e0606461026387916f91bb2f6058c57ea1df4fab053cc676"
dependencies = [
 "atomic",
 "bytes",
 "futures",
 "futures-timer",
 "getrandom 0.2.8",
 "instant",
 "lazy_static",
 "libp2p-autonat",
 "libp2p-core",
 "libp2p-deflate",
 "libp2p-dns",
 "libp2p-floodsub",
 "libp2p-gossipsub",
 "libp2p-identify",
 "libp2p-kad",
 "libp2p-mdns",
 "libp2p-metrics",
 "libp2p-mplex",
 "libp2p-noise",
 "libp2p-ping",
 "libp2p-plaintext",
 "libp2p-pnet",
 "libp2p-relay",
 "libp2p-rendezvous",
 "libp2p-request-response",
 "libp2p-quic",
 "libp2p-swarm",
 "libp2p-swarm-derive",
 "libp2p-tcp",
 "libp2p-uds",
 "libp2p-wasm-ext",
 "libp2p-websocket",
 "libp2p-yamux",
 "multiaddr",
 "parking_lot 0.12.1",
 "pin-project 1.0.12",
 "rand 0.7.3",
 "pin-project",
 "smallvec 1.10.0",
]

[[package]]
name = "libp2p-autonat"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a13b690e65046af6a09c0b27bd9508fa1cab0efce889de74b0b643b9d2a98f9a"
dependencies = [
 "async-trait",
 "futures",
 "futures-timer",
 "instant",
 "libp2p-core",
 "libp2p-request-response",
 "libp2p-swarm",
 "log",
 "prost",
 "prost-build",
 "rand 0.8.5",
]

[[package]]
name = "libp2p-core"
version = "0.32.1"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db5b02602099fb75cb2d16f9ea860a320d6eb82ce41e95ab680912c454805cd5"
checksum = "881d9a54e97d97cdaa4125d48269d97ca8c40e5fefec6b85b30440dc60cc551f"
dependencies = [
 "asn1_der",
 "bs58",


@@ 1313,19 1311,18 @@ dependencies = [
 "futures",
 "futures-timer",
 "instant",
 "lazy_static",
 "libsecp256k1",
 "log",
 "multiaddr",
 "multihash",
 "multistream-select",
 "once_cell",
 "parking_lot 0.12.1",
 "pin-project 1.0.12",
 "pin-project",
 "prost",
 "prost-build",
 "rand 0.8.5",
 "ring",
 "rw-stream-sink",
 "sec1",
 "sha2 0.10.6",
 "smallvec 1.10.0",
 "thiserror",


@@ 1335,56 1332,28 @@ dependencies = [
]

[[package]]
name = "libp2p-deflate"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b1d37f042f748e224f04785d0e987ae09a2aa518d6401d82d412dad83e360ed"
dependencies = [
 "flate2",
 "futures",
 "libp2p-core",
]

[[package]]
name = "libp2p-dns"
version = "0.32.1"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "066e33e854e10b5c93fc650458bf2179c7e0d143db260b0963e44a94859817f1"
checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554"
dependencies = [
 "async-std-resolver",
 "futures",
 "libp2p-core",
 "log",
 "parking_lot 0.12.1",
 "smallvec 1.10.0",
 "trust-dns-resolver",
]

[[package]]
name = "libp2p-floodsub"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "733d3ea6ebe7a7a85df2bc86678b93f24b015fae5fe3b3acc4c400e795a55d2d"
dependencies = [
 "cuckoofilter",
 "fnv",
 "futures",
 "libp2p-core",
 "libp2p-swarm",
 "log",
 "prost",
 "prost-build",
 "rand 0.7.3",
 "smallvec 1.10.0",
]

[[package]]
name = "libp2p-gossipsub"
version = "0.37.0"
version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a90c989a7c0969c2ab63e898da9bc735e3be53fb4f376e9c045ce516bcc9f928"
checksum = "76bb8ba6fea034eaad4eed2d0ac77dd6f2c0bc5fc4ff8ead4c7a8d37d27e5b01"
dependencies = [
 "asynchronous-codec",
 "base64",
 "base64 0.21.0",
 "byteorder",
 "bytes",
 "fnv",


@@ 1397,36 1366,21 @@ dependencies = [
 "prometheus-client",
 "prost",
 "prost-build",
 "rand 0.7.3",
 "prost-codec",
 "rand 0.8.5",
 "regex",
 "sha2 0.10.6",
 "smallvec 1.10.0",
 "thiserror",
 "unsigned-varint",
 "wasm-timer",
]

[[package]]
name = "libp2p-identify"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5ef5a5b57904c7c33d6713ef918d239dc6b7553458f3475d87f8a18e9c651c8"
dependencies = [
 "futures",
 "futures-timer",
 "libp2p-core",
 "libp2p-swarm",
 "log",
 "lru",
 "prost",
 "prost-build",
 "smallvec 1.10.0",
]

[[package]]
name = "libp2p-kad"
version = "0.36.0"
version = "0.43.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "564e6bd64d177446399ed835b9451a8825b07929d6daa6a94e6405592974725e"
checksum = "7fc257f261ecf91bf55dd2ab439c928a05e3099c182d66cd332b28a203a98c84"
dependencies = [
 "arrayvec",
 "asynchronous-codec",


@@ 1441,7 1395,7 @@ dependencies = [
 "log",
 "prost",
 "prost-build",
 "rand 0.7.3",
 "rand 0.8.5",
 "sha2 0.10.6",
 "smallvec 1.10.0",
 "thiserror",


@@ 1452,46 1406,43 @@ dependencies = [

[[package]]
name = "libp2p-mdns"
version = "0.36.0"
version = "0.43.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "611ae873c8e280ccfab0d57c7a13cac5644f364529e233114ff07863946058b0"
checksum = "687a0b54ee8f7106be36f012b32bd30faceeb4cd857ebad96e512566886ffea5"
dependencies = [
 "async-io",
 "data-encoding",
 "dns-parser",
 "futures",
 "if-watch",
 "lazy_static",
 "libp2p-core",
 "libp2p-swarm",
 "log",
 "rand 0.8.5",
 "smallvec 1.10.0",
 "socket2",
 "trust-dns-proto",
 "void",
]

[[package]]
name = "libp2p-metrics"
version = "0.5.0"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985be799bb3796e0c136c768208c3c06604a38430571906a13dcfeda225a3b9d"
checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46"
dependencies = [
 "libp2p-core",
 "libp2p-gossipsub",
 "libp2p-identify",
 "libp2p-kad",
 "libp2p-ping",
 "libp2p-relay",
 "libp2p-swarm",
 "prometheus-client",
]

[[package]]
name = "libp2p-mplex"
version = "0.32.0"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "442eb0c9fff0bf22a34f015724b4143ce01877e079ed0963c722d94c07c72160"
checksum = "4d34780b514b159e6f3fd70ba3e72664ec89da28dca2d1e7856ee55e2c7031ba"
dependencies = [
 "asynchronous-codec",
 "bytes",


@@ 1500,88 1451,40 @@ dependencies = [
 "log",
 "nohash-hasher",
 "parking_lot 0.12.1",
 "rand 0.7.3",
 "rand 0.8.5",
 "smallvec 1.10.0",
 "unsigned-varint",
]

[[package]]
name = "libp2p-noise"
version = "0.35.0"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dd7e0c94051cda67123be68cf6b65211ba3dde7277be9068412de3e7ffd63ef"
checksum = "1216f9ec823ac7a2289b954674c54cbce81c9e45920b4fcf173018ede4295246"
dependencies = [
 "bytes",
 "curve25519-dalek 3.2.1",
 "curve25519-dalek 3.2.0",
 "futures",
 "lazy_static",
 "libp2p-core",
 "log",
 "once_cell",
 "prost",
 "prost-build",
 "rand 0.8.5",
 "sha2 0.10.6",
 "snow",
 "static_assertions",
 "thiserror",
 "x25519-dalek",
 "zeroize",
]

[[package]]
name = "libp2p-ping"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf57a3c2e821331dda9fe612d4654d676ab6e33d18d9434a18cced72630df6ad"
dependencies = [
 "futures",
 "futures-timer",
 "instant",
 "libp2p-core",
 "libp2p-swarm",
 "log",
 "rand 0.7.3",
 "void",
]

[[package]]
name = "libp2p-plaintext"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "962c0fb0e7212fb96a69b87f2d09bcefd317935239bdc79cda900e7a8897a3fe"
dependencies = [
 "asynchronous-codec",
 "bytes",
 "futures",
 "libp2p-core",
 "log",
 "prost",
 "prost-build",
 "unsigned-varint",
 "void",
]

[[package]]
name = "libp2p-pnet"
version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de160c5631696cea22be326c19bd9d306e254c4964945263aea10f25f6e0864e"
dependencies = [
 "futures",
 "log",
 "pin-project 1.0.12",
 "rand 0.8.5",
 "salsa20",
 "sha3",
]

[[package]]
name = "libp2p-relay"
version = "0.8.0"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3aa754cb7bccef51ebc3c458c6bbcef89d83b578a9925438389be841527d408f"
checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202"
dependencies = [
 "asynchronous-codec",
 "bytes",
 "either",
 "futures",
 "futures-timer",


@@ 1589,73 1492,48 @@ dependencies = [
 "libp2p-core",
 "libp2p-swarm",
 "log",
 "pin-project 1.0.12",
 "prost",
 "prost-build",
 "rand 0.8.5",
 "smallvec 1.10.0",
 "static_assertions",
 "thiserror",
 "unsigned-varint",
 "void",
]

[[package]]
name = "libp2p-rendezvous"
version = "0.5.0"
name = "libp2p-quic"
version = "0.7.0-alpha.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd0baab894c5b84da510b915d53264d566c3c35889f09931fe9edbd2a773bee"
checksum = "5971f629ff7519f4d4889a7c981f0dc09c6ad493423cd8a13ee442de241bc8c8"
dependencies = [
 "asynchronous-codec",
 "bimap",
 "async-std",
 "bytes",
 "futures",
 "futures-timer",
 "instant",
 "if-watch",
 "libp2p-core",
 "libp2p-swarm",
 "libp2p-tls",
 "log",
 "prost",
 "prost-build",
 "parking_lot 0.12.1",
 "quinn-proto",
 "rand 0.8.5",
 "sha2 0.10.6",
 "rustls",
 "thiserror",
 "unsigned-varint",
 "void",
]

[[package]]
name = "libp2p-request-response"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6a6fc6c9ad95661f46989473b34bd2993d14a4de497ff3b2668a910d4b869"
dependencies = [
 "async-trait",
 "bytes",
 "futures",
 "instant",
 "libp2p-core",
 "libp2p-swarm",
 "log",
 "rand 0.7.3",
 "smallvec 1.10.0",
 "unsigned-varint",
]

[[package]]
name = "libp2p-swarm"
version = "0.35.0"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f0c69ad9e8f7c5fc50ad5ad9c7c8b57f33716532a2b623197f69f93e374d14c"
checksum = "92c22a83d70703d140092c969c1ca06ecdffff8ca7ce8ac2fd3b7eb2c1f0da86"
dependencies = [
 "async-std",
 "either",
 "fnv",
 "futures",
 "futures-timer",
 "instant",
 "libp2p-core",
 "libp2p-swarm-derive",
 "log",
 "pin-project 1.0.12",
 "rand 0.7.3",
 "pin-project",
 "rand 0.8.5",
 "smallvec 1.10.0",
 "thiserror",
 "void",


@@ 1663,25 1541,25 @@ dependencies = [

[[package]]
name = "libp2p-swarm-derive"
version = "0.27.2"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f693c8c68213034d472cbb93a379c63f4f307d97c06f1c41e4985de481687a5"
checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f"
dependencies = [
 "heck",
 "quote",
 "syn",
]

[[package]]
name = "libp2p-tcp"
version = "0.32.0"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "193447aa729c85aac2376828df76d171c1a589c9e6b58fcc7f9d9a020734122c"
checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf"
dependencies = [
 "async-io",
 "futures",
 "futures-timer",
 "if-watch",
 "ipnet",
 "libc",
 "libp2p-core",
 "log",


@@ 1689,119 1567,21 @@ dependencies = [
]

[[package]]
name = "libp2p-uds"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24bdab114f7f2701757d6541266e1131b429bbae382008f207f2114ee4222dcb"
dependencies = [
 "async-std",
 "futures",
 "libp2p-core",
 "log",
]

[[package]]
name = "libp2p-wasm-ext"
version = "0.32.0"
name = "libp2p-tls"
version = "0.1.0-alpha.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f6ea0f84a967ef59a16083f222c18115ae2e91db69809dce275df62e101b279"
checksum = "e9baf6f6292149e124ee737d9a79dbee783f29473fc368c7faad9d157841078a"
dependencies = [
 "futures",
 "js-sys",
 "libp2p-core",
 "parity-send-wrapper",
 "wasm-bindgen",
 "wasm-bindgen-futures",
]

[[package]]
name = "libp2p-websocket"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c932834c3754501c368d1bf3d0fb458487a642b90fc25df082a3a2f3d3b32e37"
dependencies = [
 "either",
 "futures",
 "futures-rustls",
 "libp2p-core",
 "log",
 "quicksink",
 "rw-stream-sink",
 "soketto",
 "url",
 "webpki-roots",
]

[[package]]
name = "libp2p-yamux"
version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be902ebd89193cd020e89e89107726a38cfc0d16d18f613f4a37d046e92c7517"
dependencies = [
 "futures",
 "libp2p-core",
 "parking_lot 0.12.1",
 "rcgen",
 "ring",
 "rustls",
 "thiserror",
 "yamux",
]

[[package]]
name = "libsecp256k1"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1"
dependencies = [
 "arrayref",
 "base64",
 "digest 0.9.0",
 "hmac-drbg",
 "libsecp256k1-core",
 "libsecp256k1-gen-ecmult",
 "libsecp256k1-gen-genmult",
 "rand 0.8.5",
 "serde",
 "sha2 0.9.9",
 "typenum",
]

[[package]]
name = "libsecp256k1-core"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451"
dependencies = [
 "crunchy",
 "digest 0.9.0",
 "subtle",
]

[[package]]
name = "libsecp256k1-gen-ecmult"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809"
dependencies = [
 "libsecp256k1-core",
]

[[package]]
name = "libsecp256k1-gen-genmult"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c"
dependencies = [
 "libsecp256k1-core",
]

[[package]]
name = "libz-sys"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf"
dependencies = [
 "cc",
 "pkg-config",
 "vcpkg",
 "webpki",
 "x509-parser",
 "yasna",
]

[[package]]


@@ 1822,7 1602,6 @@ version = "0.0.1"
dependencies = [
 "async-std",
 "futures",
 "getrandom 0.2.8",
 "libp2p",
 "macroquad",
 "nanoserde",


@@ 1851,15 1630,6 @@ dependencies = [
]

[[package]]
name = "lru"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a"
dependencies = [
 "hashbrown 0.12.3",
]

[[package]]
name = "lru-cache"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1924,6 1694,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"

[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"

[[package]]
name = "miniquad"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1945,15 1721,27 @@ dependencies = [
]

[[package]]
name = "mio"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
dependencies = [
 "libc",
 "log",
 "wasi 0.11.0+wasi-snapshot-preview1",
 "windows-sys 0.45.0",
]

[[package]]
name = "multiaddr"
version = "0.14.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261"
checksum = "3b53e0cc5907a5c216ba6584bf74be8ab47d6d6289f72793b2dddbf15dc3bf8c"
dependencies = [
 "arrayref",
 "bs58",
 "byteorder",
 "data-encoding",
 "multibase",
 "multihash",
 "percent-encoding",
 "serde",


@@ 1963,10 1751,21 @@ dependencies = [
]

[[package]]
name = "multibase"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404"
dependencies = [
 "base-x",
 "data-encoding",
 "data-encoding-macro",
]

[[package]]
name = "multihash"
version = "0.16.3"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc"
checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40"
dependencies = [
 "core2",
 "digest 0.10.6",


@@ 1997,14 1796,14 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"

[[package]]
name = "multistream-select"
version = "0.11.0"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "363a84be6453a70e63513660f4894ef815daf88e3356bffcda9ca27d810ce83b"
checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a"
dependencies = [
 "bytes",
 "futures",
 "log",
 "pin-project 1.0.12",
 "pin-project",
 "smallvec 1.10.0",
 "unsigned-varint",
]


@@ 2111,7 1910,28 @@ dependencies = [
name = "nohash-hasher"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"

[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
 "memchr",
 "minimal-lexical",
]

[[package]]
name = "num-bigint"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
dependencies = [
 "autocfg",
 "num-integer",
 "num-traits",
]

[[package]]
name = "num-integer"


@@ 2172,6 1992,15 @@ dependencies = [
]

[[package]]
name = "oid-registry"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff"
dependencies = [
 "asn1-rs",
]

[[package]]
name = "once_cell"
version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2184,15 2013,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"

[[package]]
name = "owning_ref"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce"
dependencies = [
 "stable_deref_trait",
]

[[package]]
name = "packed_simd_2"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2203,12 2023,6 @@ dependencies = [
]

[[package]]
name = "parity-send-wrapper"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"

[[package]]
name = "parking"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2269,6 2083,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"

[[package]]
name = "pem"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8"
dependencies = [
 "base64 0.13.1",
]

[[package]]
name = "percent-encoding"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2286,31 2109,11 @@ dependencies = [

[[package]]
name = "pin-project"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ef0f924a5ee7ea9cbcea77529dba45f8a9ba9f622419fe3386ca581a3ae9d5a"
dependencies = [
 "pin-project-internal 0.4.30",
]

[[package]]
name = "pin-project"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
dependencies = [
 "pin-project-internal 1.0.12",
]

[[package]]
name = "pin-project-internal"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "851c8d0ce9bebe43790dedfc86614c23494ac9f423dd618d3a61fc693eafe61e"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
 "pin-project-internal",
]

[[package]]


@@ 2326,12 2129,6 @@ dependencies = [

[[package]]
name = "pin-project-lite"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777"

[[package]]
name = "pin-project-lite"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"


@@ 2343,10 2140,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"

[[package]]
name = "pkg-config"
version = "0.3.26"
name = "pkcs8"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba"
dependencies = [
 "der",
 "spki",
]

[[package]]
name = "platforms"


@@ 2410,6 2211,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"

[[package]]
name = "prettyplease"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78"
dependencies = [
 "proc-macro2",
 "syn",
]

[[package]]
name = "proc-macro-crate"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2454,21 2265,21 @@ dependencies = [

[[package]]
name = "prometheus-client"
version = "0.15.1"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9a896938cc6018c64f279888b8c7559d3725210d5db9a3a1ee6bc7188d51d34"
checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e"
dependencies = [
 "dtoa",
 "itoa",
 "owning_ref",
 "prometheus-client-derive-text-encode",
 "parking_lot 0.12.1",
 "prometheus-client-derive-encode",
]

[[package]]
name = "prometheus-client-derive-text-encode"
version = "0.2.0"
name = "prometheus-client-derive-encode"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8e12d01b9d66ad9eb4529c57666b6263fc1993cb30261d83ead658fdd932652"
checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1"
dependencies = [
 "proc-macro2",
 "quote",


@@ 2477,9 2288,9 @@ dependencies = [

[[package]]
name = "prost"
version = "0.9.0"
version = "0.11.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537"
dependencies = [
 "bytes",
 "prost-derive",


@@ 2487,29 2298,44 @@ dependencies = [

[[package]]
name = "prost-build"
version = "0.9.0"
version = "0.11.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
checksum = "2c828f93f5ca4826f97fedcbd3f9a536c16b12cff3dbbb4a007f932bbad95b12"
dependencies = [
 "bytes",
 "heck 0.3.3",
 "heck",
 "itertools",
 "lazy_static",
 "log",
 "multimap",
 "petgraph",
 "prettyplease",
 "prost",
 "prost-types",
 "regex",
 "syn",
 "tempfile",
 "which",
]

[[package]]
name = "prost-codec"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dc34979ff898b6e141106178981ce2596c387ea6e62533facfc61a37fc879c0"
dependencies = [
 "asynchronous-codec",
 "bytes",
 "prost",
 "thiserror",
 "unsigned-varint",
]

[[package]]
name = "prost-derive"
version = "0.9.0"
version = "0.11.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b"
dependencies = [
 "anyhow",
 "itertools",


@@ 2520,11 2346,10 @@ dependencies = [

[[package]]
name = "prost-types"
version = "0.9.0"
version = "0.11.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88"
dependencies = [
 "bytes",
 "prost",
]



@@ 2578,19 2403,26 @@ dependencies = [

[[package]]
name = "quick-error"
version = "1.1.0"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0aad603e8d7fb67da22dbdf1f4b826ce8829e406124109e73cf1b2454b93a71c"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"

[[package]]
name = "quicksink"
version = "0.1.2"
name = "quinn-proto"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858"
checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9"
dependencies = [
 "futures-core",
 "futures-sink",
 "pin-project-lite 0.1.12",
 "bytes",
 "rand 0.8.5",
 "ring",
 "rustc-hash",
 "rustls",
 "slab",
 "thiserror",
 "tinyvec",
 "tracing",
 "webpki",
]

[[package]]


@@ 2674,6 2506,18 @@ dependencies = [
]

[[package]]
name = "rcgen"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b"
dependencies = [
 "pem",
 "ring",
 "time",
 "yasna",
]

[[package]]
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2740,6 2584,12 @@ dependencies = [
]

[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"

[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2749,6 2599,15 @@ dependencies = [
]

[[package]]
name = "rusticata-macros"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632"
dependencies = [
 "nom",
]

[[package]]
name = "rustix"
version = "0.36.8"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2776,25 2635,16 @@ dependencies = [

[[package]]
name = "rw-stream-sink"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020"
checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04"
dependencies = [
 "futures",
 "pin-project 0.4.30",
 "pin-project",
 "static_assertions",
]

[[package]]
name = "salsa20"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"
dependencies = [
 "cipher 0.4.3",
]

[[package]]
name = "sapp-jsutils"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2817,6 2667,19 @@ dependencies = [
]

[[package]]
name = "sec1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928"
dependencies = [
 "base16ct",
 "der",
 "generic-array",
 "pkcs8",
 "zeroize",
]

[[package]]
name = "semver"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2827,33 2690,6 @@ name = "serde"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
dependencies = [
 "serde_derive",
]

[[package]]
name = "serde_derive"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "sha-1"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
dependencies = [
 "block-buffer 0.9.0",
 "cfg-if",
 "cpufeatures",
 "digest 0.9.0",
 "opaque-debug",
]

[[package]]
name = "sha2"


@@ 2880,16 2716,6 @@ dependencies = [
]

[[package]]
name = "sha3"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9"
dependencies = [
 "digest 0.10.6",
 "keccak",
]

[[package]]
name = "signal-hook"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2939,6 2765,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"

[[package]]
name = "smol"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13f2b548cd8447f8de0fdf1c592929f70f4fc7039a05e47404b0d096ec6987a1"
dependencies = [
 "async-channel",
 "async-executor",
 "async-fs",
 "async-io",
 "async-lock",
 "async-net",
 "async-process",
 "blocking",
 "futures-lite",
]

[[package]]
name = "snow"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2966,32 2809,20 @@ dependencies = [
]

[[package]]
name = "soketto"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2"
dependencies = [
 "base64",
 "bytes",
 "flate2",
 "futures",
 "httparse",
 "log",
 "rand 0.8.5",
 "sha-1",
]

[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"

[[package]]
name = "stable_deref_trait"
version = "1.2.0"
name = "spki"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b"
dependencies = [
 "base64ct",
 "der",
]

[[package]]
name = "static_assertions"


@@ 3083,6 2914,33 @@ dependencies = [
]

[[package]]
name = "time"
version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890"
dependencies = [
 "itoa",
 "serde",
 "time-core",
 "time-macros",
]

[[package]]
name = "time-core"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd"

[[package]]
name = "time-macros"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36"
dependencies = [
 "time-core",
]

[[package]]
name = "tinyvec"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 3105,8 2963,12 @@ checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af"
dependencies = [
 "autocfg",
 "bytes",
 "libc",
 "memchr",
 "pin-project-lite 0.2.9",
 "mio",
 "num_cpus",
 "pin-project-lite",
 "socket2",
 "windows-sys 0.42.0",
]



@@ 3120,10 2982,42 @@ dependencies = [
]

[[package]]
name = "tracing"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
 "cfg-if",
 "pin-project-lite",
 "tracing-attributes",
 "tracing-core",
]

[[package]]
name = "tracing-attributes"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "tracing-core"
version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
dependencies = [
 "once_cell",
]

[[package]]
name = "trust-dns-proto"
version = "0.21.2"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d"
checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26"
dependencies = [
 "async-trait",
 "cfg-if",


@@ 3135,30 3029,32 @@ dependencies = [
 "idna 0.2.3",
 "ipnet",
 "lazy_static",
 "log",
 "rand 0.8.5",
 "smallvec 1.10.0",
 "socket2",
 "thiserror",
 "tinyvec",
 "tokio",
 "tracing",
 "url",
]

[[package]]
name = "trust-dns-resolver"
version = "0.21.2"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558"
checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe"
dependencies = [
 "cfg-if",
 "futures-util",
 "ipconfig",
 "lazy_static",
 "log",
 "lru-cache",
 "parking_lot 0.12.1",
 "resolv-conf",
 "smallvec 1.10.0",
 "thiserror",
 "tracing",
 "trust-dns-proto",
]



@@ 3208,12 3104,6 @@ dependencies = [
]

[[package]]
name = "unicode-segmentation"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"

[[package]]
name = "unicode-xid"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 3237,8 3127,6 @@ checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836"
dependencies = [
 "asynchronous-codec",
 "bytes",
 "futures-io",
 "futures-util",
]

[[package]]


@@ 3269,12 3157,6 @@ dependencies = [
]

[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"

[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 3406,15 3288,6 @@ dependencies = [
]

[[package]]
name = "webpki-roots"
version = "0.22.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
dependencies = [
 "webpki",
]

[[package]]
name = "wepoll-ffi"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 3597,34 3470,47 @@ dependencies = [

[[package]]
name = "x25519-dalek"
version = "1.2.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2392b6b94a576b4e2bf3c5b2757d63f10ada8020a2e4d08ac849ebcf6ea8e077"
checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f"
dependencies = [
 "curve25519-dalek 3.2.1",
 "curve25519-dalek 3.2.0",
 "rand_core 0.5.1",
 "zeroize",
]

[[package]]
name = "yamux"
version = "0.10.2"
name = "x509-parser"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8"
dependencies = [
 "asn1-rs",
 "base64 0.13.1",
 "data-encoding",
 "der-parser",
 "lazy_static",
 "nom",
 "oid-registry",
 "rusticata-macros",
 "thiserror",
 "time",
]

[[package]]
name = "yasna"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5"
checksum = "aed2e7a52e3744ab4d0c05c20aa065258e84c49fd4226f5191b2ed29712710b4"
dependencies = [
 "futures",
 "log",
 "nohash-hasher",
 "parking_lot 0.12.1",
 "rand 0.8.5",
 "static_assertions",
 "time",
]

[[package]]
name = "zeroize"
version = "1.3.0"
version = "1.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd"
checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f"
dependencies = [
 "zeroize_derive",
]

M Cargo.toml => Cargo.toml +8 -6
@@ 12,7 12,7 @@ keywords = ["game", "isometric", "town", "macroquad"]

[features]
default = ["multiplayer"]
multiplayer = ["libp2p", "futures", "async-std", "getrandom"]
multiplayer = ["libp2p", "futures", "async-std", "quad-rand"]

[dependencies]
macroquad = "0.3.25"


@@ 20,8 20,10 @@ nanoserde = "0.1.32"
quad-storage = "0.1.3"

# p2p dependencies
libp2p = { version = "0.44.0", optional = true }
futures = { version = "0.3.21", optional = true }
async-std = { version = "1.11.0", optional = true }
getrandom = { version = "0.2", features = ["js"], optional = true }
quad-rand = "0.2.1"
libp2p = { version = "0.51.0", features = [
"mdns", "gossipsub", "kad", "mplex",
"ping", "noise", "tcp", "async-std", "macros",
], optional = true }
futures = { version = "0.3.26", optional = true }
async-std = { version = "1.12.0", optional = true }
quad-rand = { version = "0.2.1", optional = true }

M src/p2p.rs => src/p2p.rs +78 -172
@@ 1,8 1,3 @@
// templated from poemhub
// https://codeberg.org/comcloudway/poemhub/raw/branch/main/poemhub-peer/src/lib.rs
// licensed under AGPL-3.0

use async_std::task;
use futures::{
    prelude::stream::StreamExt,
    channel:: mpsc::{


@@ 12,18 7,18 @@ use futures::{
    select,
};
use libp2p::{
    floodsub::{self, Floodsub, FloodsubEvent},
    gossipsub,
    identity,
    kad::{
        Kademlia,
        KademliaConfig,
        KademliaEvent,
        record::store::MemoryStore
    },
    mdns::{Mdns, MdnsConfig, MdnsEvent},
    mdns,
    tcp,
    mplex,
    noise,
    core::upgrade,
    swarm::keep_alive,
    swarm::SwarmEvent,
    Multiaddr, NetworkBehaviour, PeerId, Swarm,
    ping, Transport
    swarm::NetworkBehaviour,
    PeerId, Swarm,
    Transport
};
use std::{
    collections::HashMap,


@@ 37,6 32,9 @@ use std::{
        SystemTime
    }
};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::time::Duration;
use nanoserde::{SerJson, DeJson};
use crate::blocks::Block;
use crate::types::{


@@ 44,86 42,22 @@ use crate::types::{
    Direction
};

/// a collection of a PeerId and a MultiAddress
/// used to connect to external servers
pub type Bootnode = (PeerId, Multiaddr);
/// a bootnode collection
pub type Bootnodes = Vec<Bootnode>;

/// A custom network behaviour that combines floodsub, ping and mDNS.
/// floodsub is used to broadcast messages and events
/// ping is used to keep the connection alive
/// mDNS is used for peer discovery
#[derive(NetworkBehaviour)]
#[behaviour(out_event = "PeerEvent")]
struct PeerBehaviour {
    /// for message broadcasting
    floodsub: Floodsub,
    gossipsub: gossipsub::Behaviour,
    /// for local peer discovery
    mdns: Mdns,
    mdns: mdns::async_io::Behaviour,
    /// to keep connection alive
    ping: ping::Behaviour,
    /// for bootnode based external peer discovery
    kademlia: Kademlia<MemoryStore>,

    // Struct fields which do not implement NetworkBehaviour need to be ignored
    #[behaviour(ignore)]
    #[allow(dead_code)]
    ignored_member: bool,
}
impl PeerBehaviour {
    pub fn new(local_peer_id: PeerId) -> Self {
        let mdns = task::block_on(Mdns::new(MdnsConfig::default())).expect("Failed to create mDNS config");
        let kademlia_config = KademliaConfig::default();

        Self {
            floodsub: Floodsub::new(local_peer_id),
            mdns,
            kademlia: Kademlia::with_config(local_peer_id, MemoryStore::new(local_peer_id), kademlia_config),
            ping: ping::Behaviour::new(ping::Config::new().with_keep_alive(true)),
            ignored_member: false,
        }
    }
}

#[derive(Debug)]
/// events that can be received by network Behaviour
enum PeerEvent {
    /// events from floodsub protocol
    /// used to communicate between the peers
    Floodsub(FloodsubEvent),
    /// events from mDNS protocol
    /// used for peer discovery in local network
    Mdns(MdnsEvent),
    /// events from ping protocol
    /// used to keep connection alive
    /// no real reson to actually store them
    Ping(ping::Event),
    Kademlia(KademliaEvent),
}
impl From<MdnsEvent> for PeerEvent {
    fn from(v: MdnsEvent) -> Self {
        Self::Mdns(v)
    }
}
impl From<FloodsubEvent> for PeerEvent {
    fn from(v: FloodsubEvent) -> Self {
        Self::Floodsub(v)
    }
}
impl From<ping::Event> for PeerEvent {
    fn from(v: ping::Event) -> Self {
        Self::Ping(v)
    }
}
impl From<KademliaEvent> for PeerEvent {
    fn from(v: KademliaEvent) -> Self {
        Self::Kademlia(v)
    }
    keep_alive: keep_alive::Behaviour,
}

/// the topic using which data is broadcasted
const FLOODSUB_TOPIC: &str = "little-town";
const TOPIC: &str = "little-town";

/// a GameEvent worth while broadcasting to peers
#[derive(DeJson, SerJson)]


@@ 159,10 93,6 @@ enum ChannelEvent {

/// struct to manage all relevant options for connection with poemhub p2p network
pub struct Peer {
    /// a list of known bootnodes,
    /// should be provided by the application
    /// NOTE: you might want to fetch a bootnode list from a file server
    bootnodes: Bootnodes,
    /// the local port to run on
    /// recommended for bootnodes to be able to do port forwarding
    /// NOTE: should only be used when running as bootnode


@@ 186,7 116,6 @@ impl Peer {
        let mut this = Self {
            bridge: None,
            port: None,
            bootnodes: Vec::new(),
            incoming: Arc::new(RwLock::new(Vec::new())),
            is_host: false
        };


@@ 199,7 128,6 @@ impl Peer {
        let mut this = Self {
            bridge: None,
            port: None,
            bootnodes: Vec::new(),
            incoming: Arc::new(RwLock::new(Vec::new())),
            is_host: true
        };


@@ 207,20 135,12 @@ impl Peer {
        this
    }



    /// adds a specific port to the setup
    /// has to be called before connect() is being called
    pub fn with_port(mut self, port: usize) -> Self {
        self.port = Some(port);
        self
    }
    /// appends the given bootnode to the bootnodes list
    /// has to be called before connect() is being called
    pub fn with_bootnode(mut self, node: Bootnode) -> Self {
        self.bootnodes.push(node);
        self
    }

    /// closes the connection to the p2p network
    /// obviously requires you to connect beforehand


@@ 268,7 188,6 @@ impl Peer {
        let (tx, mut rx) = mpsc::unbounded::<ChannelEvent>();
        self.bridge=Some(tx);

        let bootnodes = self.bootnodes.clone();
        let port = self.port;
        let inbox = self.incoming.clone();
        let is_host = self.is_host.clone();


@@ 277,57 196,52 @@ impl Peer {
            let local_key = identity::Keypair::generate_ed25519();
            let local_peer_id = PeerId::from(local_key.public());

            // Set up an encrypted DNS-enabled TCP Transport over the Mplex and Yamux protocols
            let transport = libp2p::tcp::TcpConfig::new()
                .upgrade(libp2p::core::upgrade::Version::V1)
                .authenticate(libp2p::noise::NoiseConfig::xx(
                    libp2p::noise::Keypair::<libp2p::noise::X25519Spec>::new()
                        .into_authentic(&local_key)
                        .expect("Setting up noise encryption failed")
                ).into_authenticated())
                .multiplex(libp2p::mplex::MplexConfig::new())
            let transport = tcp::async_io::Transport::new(tcp::Config::default().nodelay(true))
                .upgrade(upgrade::Version::V1)
                .authenticate(
                    noise::NoiseAuthenticated::xx(&local_key)
                        .expect("Signing libp2p-noise static DH keypair failed."),
                )
                .multiplex(mplex::MplexConfig::new())
                .boxed();

            // Create a Floodsub topic
            let floodsub_topic = floodsub::Topic::new(FLOODSUB_TOPIC);
            // To content-address message, we can take the hash of message and use it as an ID.
            let message_id_fn = |message: &gossipsub::Message| {
                let mut s = DefaultHasher::new();
                message.data.hash(&mut s);
                gossipsub::MessageId::from(s.finish().to_string())
            };

            // Set a custom gossipsub configuration
            let gossipsub_config = gossipsub::ConfigBuilder::default()
                .heartbeat_interval(Duration::from_secs(10)) // This is set to aid debugging by not cluttering the log space
                .validation_mode(gossipsub::ValidationMode::Strict) // This sets the kind of message validation. The default is Strict (enforce message signing)
                .message_id_fn(message_id_fn) // content-address messages. No two messages of the same content will be propagated.
                .build()
                .expect("Valid config");

            let mut gossipsub = gossipsub::Behaviour::new(
                gossipsub::MessageAuthenticity::Signed(local_key),
                gossipsub_config,
            )
                .expect("Correct configuration");

            // Create a topic
            let topic = gossipsub::IdentTopic::new(TOPIC);
            gossipsub.subscribe(&topic);

            // Create a Swarm to manage peers and events
            let mut swarm = {
                let mut behaviour = PeerBehaviour::new(local_peer_id);
                let mdns = mdns::Behaviour::new(mdns::Config::default(), local_peer_id).unwrap();

                behaviour.floodsub.subscribe(floodsub_topic.clone());
                Swarm::new(transport, behaviour, local_peer_id)
                let behaviour = PeerBehaviour {
                    gossipsub,
                    mdns,
                    keep_alive: Default::default()
                };
                Swarm::with_async_std_executor(transport, behaviour, local_peer_id)
            };

            // Reach out to another node if specified
            let mut i = 0;
            while let Some(to_dial) = bootnodes.get(i) {
                i+=1;
                let (peer_id, addr) = to_dial;
                swarm
                    .behaviour_mut()
                    .kademlia
                    .add_address(
                        &peer_id,
                        addr.clone()
                    );
                swarm.behaviour_mut()
                     .floodsub
                     .add_node_to_partial_view(peer_id.clone());
            }

            swarm
                .behaviour_mut()
                .kademlia
                .get_closest_peers(local_peer_id);
            if !bootnodes.is_empty() {
                swarm
                    .behaviour_mut()
                    .kademlia
                    .bootstrap()
                    .expect("Failed to bootstrap kademlia");
            }

            // Listen on all interfaces and whatever port the OS assigns
            quad_rand::srand(SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs());
            let port = port.unwrap_or(quad_rand::gen_range(4000, 9999));


@@ 339,17 253,15 @@ impl Peer {
                    .expect("Failed to parse provided port"))
                 .expect("Failed to start p2p network");


            loop {
                select!{
                    bridge_event = rx.select_next_some() => match bridge_event {
                        ChannelEvent::Action(act) => {
                            let json = act.serialize_json();
                            println!("sending json: {}", json);
                            swarm
                                .behaviour_mut()
                                .floodsub
                                .publish_any(floodsub_topic.clone(), json.as_bytes())
                                .gossipsub
                                .publish(topic.clone(), json.as_bytes());
                        },
                        ChannelEvent::Quit => break,
                    },


@@ 358,12 270,15 @@ impl Peer {
                        SwarmEvent::NewListenAddr { address, .. } => {
                            println!("Listening on {:?}", address);
                        }
                        SwarmEvent::Behaviour(PeerEvent::Floodsub(
                            FloodsubEvent::Message(message)
                        SwarmEvent::Behaviour(PeerBehaviourEvent::Gossipsub(
                            gossipsub::Event::Message{
                                propagation_source: _,
                                message_id: _,
                                message
                            }
                        )) => {
                            // parse incoming action
                            let text = String::from_utf8_lossy(&message.data);
                            println!("received: {}", text);
                            if let Ok(act) = GameAction::deserialize_json(&text) {
                                // hand on act to game instance
                                let may_process = if is_host {


@@ 384,8 299,8 @@ impl Peer {
                                }
                            }
                        },
                        SwarmEvent::Behaviour(PeerEvent::Floodsub(
                            FloodsubEvent::Subscribed {..}
                        SwarmEvent::Behaviour(PeerBehaviourEvent::Gossipsub(
                            gossipsub::Event::Subscribed {..}
                        )) => {
                            println!("Subscribed");
                            // ask game to broadcast world map and inventory


@@ 397,45 312,36 @@ impl Peer {
                                    let json = act.serialize_json();
                                    swarm
                                        .behaviour_mut()
                                        .floodsub
                                        .publish_any(floodsub_topic.clone(), json.as_bytes())
                                        .gossipsub
                                        .publish(topic.clone(), json.as_bytes());
                                }
                            }
                        },
                        SwarmEvent::Behaviour(PeerEvent::Mdns(
                            MdnsEvent::Discovered(list)
                        SwarmEvent::Behaviour(PeerBehaviourEvent::Mdns(
                            mdns::Event::Discovered(list)
                        )) => {
                            for (peer, a) in list {
                            for (peer, _) in list {
                                println!("Discovered {:?}", peer);
                                swarm
                                    .behaviour_mut()
                                    .kademlia
                                    .add_address(
                                        &peer,
                                        a.clone()
                                    );
                                swarm
                                    .behaviour_mut()
                                    .floodsub
                                    .add_node_to_partial_view(peer);
                                    .gossipsub
                                    .add_explicit_peer(&peer);
                            }
                        }
                        SwarmEvent::Behaviour(PeerEvent::Mdns(MdnsEvent::Expired(
                            list
                        ))) => {
                        SwarmEvent::Behaviour(PeerBehaviourEvent::Mdns(
                            mdns::Event::Expired(
                                list
                            ))) => {
                            for (peer, _) in list {
                                println!("Disconnected {:?}", peer);
                                if !swarm.behaviour_mut().mdns.has_node(&peer) {
                                    swarm
                                        .behaviour_mut()
                                        .floodsub
                                        .remove_node_from_partial_view(&peer);
                                        .gossipsub
                                        .remove_explicit_peer(&peer);
                                }
                            }
                        },
                        SwarmEvent::Behaviour(PeerEvent::Kademlia(e)) => {
                            println!("Kademlia: {:?}", e);
                        },
                        // ping events can be ignored
                        _ => {}
                    }