diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml new file mode 100644 index 0000000000..0d3fb2459f --- /dev/null +++ b/.github/workflows/build-docs.yaml @@ -0,0 +1,21 @@ +name: Build Docs + +on: + pull_request: + branches: + - master + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.0.0 + - uses: shalzz/zola-deploy-action@v0.16.1 + env: + BUILD_DIR: docs + BUILD_ONLY: true + BUILD_FLAGS: --drafts diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/deploy-docs.yaml new file mode 100644 index 0000000000..f932766ea9 --- /dev/null +++ b/.github/workflows/deploy-docs.yaml @@ -0,0 +1,20 @@ +name: Deploy Docs + +on: + push: + branches: + - master + +defaults: + run: + shell: bash + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.0.0 + - uses: shalzz/zola-deploy-action@v0.16.1 + env: + BUILD_DIR: docs + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index e3feb5c113..b104363258 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.idea/ /.vagrant /benchmark +/docs/public /index.lmdb /index.redb /ord.log diff --git a/Cargo.lock b/Cargo.lock index b3a3e8c24b..8941e515ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9a8f622bcf6ff3df478e9deba3e03e4e04b300f8e6a139e192c05fa3490afc7" +checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" dependencies = [ "backtrace", ] @@ -282,7 +282,7 @@ dependencies = [ "async-io", "autocfg 1.1.0", "blocking", - "cfg-if", + "cfg-if 1.0.0", "event-listener", "futures-lite", "libc", @@ -384,7 +384,7 @@ dependencies = [ "matchit", "memchr", "mime", - "percent-encoding", + "percent-encoding 2.2.0", "pin-project-lite", "serde", "serde_json", @@ -441,7 +441,7 @@ checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", "object", @@ -589,6 +589,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + [[package]] name = "blocking" version = "1.2.0" @@ -614,6 +623,15 @@ dependencies = [ "syn", ] +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "memchr", +] + [[package]] name = "bumpalo" version = "3.11.0" @@ -644,6 +662,12 @@ version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -676,9 +700,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.20" +version = "3.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd" +checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" dependencies = [ "atty", "bitflags", @@ -753,9 +777,9 @@ dependencies = [ "base64", "hkdf", "hmac", - "percent-encoding", + "percent-encoding 2.2.0", "rand 0.8.5", - "sha2", + "sha2 0.9.9", "time 0.2.27", "version_check", ] @@ -797,7 +821,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -806,7 +830,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -816,7 +840,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -828,7 +852,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" dependencies = [ "autocfg 1.1.0", - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "memoffset", "once_cell", @@ -841,10 +865,20 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "once_cell", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "crypto-mac" version = "0.10.1" @@ -932,6 +966,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "digest" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", +] + [[package]] name = "dirs" version = "4.0.0" @@ -999,7 +1043,7 @@ version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -1075,7 +1119,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" dependencies = [ - "percent-encoding", + "percent-encoding 2.2.0", ] [[package]] @@ -1094,6 +1138,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "futures" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" + [[package]] name = "futures" version = "0.3.24" @@ -1134,6 +1184,7 @@ dependencies = [ "futures-core", "futures-task", "futures-util", + "num_cpus", ] [[package]] @@ -1197,6 +1248,7 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ + "futures 0.1.31", "futures-channel", "futures-core", "futures-io", @@ -1243,7 +1295,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", @@ -1256,7 +1308,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.11.0+wasi-snapshot-preview1", ] @@ -1277,6 +1329,19 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +[[package]] +name = "globset" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + [[package]] name = "gloo-timers" version = "0.2.4" @@ -1304,7 +1369,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util", + "tokio-util 0.7.4", "tracing", ] @@ -1359,7 +1424,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" dependencies = [ - "digest", + "digest 0.9.0", "hmac", ] @@ -1370,7 +1435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", - "digest", + "digest 0.9.0", ] [[package]] @@ -1420,7 +1485,7 @@ dependencies = [ "serde_json", "serde_qs", "serde_urlencoded", - "url", + "url 2.3.0", ] [[package]] @@ -1480,9 +1545,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.47" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c495f162af0bf17656d0014a0eded5f3cd2f365fdd204548c2869db89359dc7" +checksum = "237a0714f28b1ee39ccec0770ccb544eb02c9ef2c82bb096230eefcffa6468b0" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1492,6 +1557,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "idna" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "idna" version = "0.2.1" @@ -1525,7 +1601,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -1542,9 +1618,9 @@ checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "js-sys" -version = "0.3.59" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] @@ -1561,6 +1637,108 @@ dependencies = [ "serde_json", ] +[[package]] +name = "jsonrpc-client-transports" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b99d4207e2a04fb4581746903c2bb7eb376f88de9c699d0f3e10feeac0cd3a" +dependencies = [ + "derive_more", + "futures 0.3.24", + "jsonrpc-core", + "jsonrpc-pubsub", + "log", + "serde", + "serde_json", + "url 1.7.2", +] + +[[package]] +name = "jsonrpc-core" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" +dependencies = [ + "futures 0.3.24", + "futures-executor", + "futures-util", + "log", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "jsonrpc-core-client" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b51da17abecbdab3e3d4f26b01c5ec075e88d3abe3ab3b05dc9aa69392764ec0" +dependencies = [ + "futures 0.3.24", + "jsonrpc-client-transports", +] + +[[package]] +name = "jsonrpc-derive" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b939a78fa820cdfcb7ee7484466746a7377760970f6f9c6fe19f9edcc8a38d2" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "jsonrpc-http-server" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff" +dependencies = [ + "futures 0.3.24", + "hyper", + "jsonrpc-core", + "jsonrpc-server-utils", + "log", + "net2", + "parking_lot", + "unicase", +] + +[[package]] +name = "jsonrpc-pubsub" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240f87695e6c6f62fb37f05c02c04953cf68d6408b8c1c89de85c7a0125b1011" +dependencies = [ + "futures 0.3.24", + "jsonrpc-core", + "lazy_static", + "log", + "parking_lot", + "rand 0.7.3", + "serde", +] + +[[package]] +name = "jsonrpc-server-utils" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4fdea130485b572c39a460d50888beb00afb3e35de23ccd7fad8ff19f0e0d4" +dependencies = [ + "bytes", + "futures 0.3.24", + "globset", + "jsonrpc-core", + "lazy_static", + "log", + "tokio", + "tokio-stream", + "tokio-util 0.6.10", + "unicase", +] + [[package]] name = "kv-log-macro" version = "1.0.7" @@ -1608,7 +1786,7 @@ version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "value-bag", ] @@ -1716,6 +1894,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "net2" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi", +] + [[package]] name = "new_mime_guess" version = "4.0.1" @@ -1733,7 +1922,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" dependencies = [ "bitflags", - "cfg-if", + "cfg-if 1.0.0", "libc", "memoffset", ] @@ -1746,7 +1935,7 @@ checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" dependencies = [ "autocfg 1.1.0", "bitflags", - "cfg-if", + "cfg-if 1.0.0", "libc", ] @@ -1846,7 +2035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0" dependencies = [ "bitflags", - "cfg-if", + "cfg-if 1.0.0", "foreign-types", "libc", "once_cell", @@ -1902,9 +2091,13 @@ dependencies = [ "dirs", "env_logger", "executable-path", - "futures", + "futures 0.3.24", "hex", "http", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "jsonrpc-http-server", "log", "mime_guess", "nix 0.24.2", @@ -1923,7 +2116,7 @@ dependencies = [ "tempfile", "tokio", "tokio-stream", - "tokio-util", + "tokio-util 0.7.4", "tower", "tower-http", "unindent", @@ -1967,7 +2160,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "instant", "libc", "redox_syscall", @@ -1984,6 +2177,12 @@ dependencies = [ "base64", ] +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" + [[package]] name = "percent-encoding" version = "2.2.0" @@ -2035,7 +2234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899b00b9c8ab553c743b3e11e87c5c7d423b2a2de229ba95b24a756344748011" dependencies = [ "autocfg 1.1.0", - "cfg-if", + "cfg-if 1.0.0", "libc", "log", "wepoll-ffi", @@ -2071,6 +2270,15 @@ dependencies = [ "yansi", ] +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -2181,7 +2389,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -2211,7 +2419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -2240,9 +2448,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom 0.2.7", ] @@ -2441,7 +2649,7 @@ dependencies = [ "log", "mime", "native-tls", - "percent-encoding", + "percent-encoding 2.2.0", "pin-project-lite", "serde", "serde_json", @@ -2449,7 +2657,7 @@ dependencies = [ "tokio", "tokio-native-tls", "tower-service", - "url", + "url 2.3.0", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -2488,9 +2696,9 @@ dependencies = [ [[package]] name = "rust-embed" -version = "6.4.0" +version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a17e5ac65b318f397182ae94e532da0ba56b88dd1200b774715d36c4943b1c3" +checksum = "e26934cd67a1da1165efe61cba4047cc1b4a526019da609fcce13a1000afb5fa" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -2499,9 +2707,9 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "6.2.0" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94e763e24ba2bf0c72bc6be883f967f794a019fafd1b86ba1daff9c91a7edd30" +checksum = "e35d7b402e273544cc08e0824aa3404333fab8a90ac43589d3d5b72f4b346e12" dependencies = [ "proc-macro2", "quote", @@ -2512,11 +2720,11 @@ dependencies = [ [[package]] name = "rust-embed-utils" -version = "7.2.0" +version = "7.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "756feca3afcbb1487a1d01f4ecd94cf8ec98ea074c55a69e7136d29fb6166029" +checksum = "c1669d81dfabd1b5f8e2856b8bbe146c6192b0ba22162edc738ac0a5de18f054" dependencies = [ - "sha2", + "sha2 0.10.6", "walkdir", ] @@ -2541,7 +2749,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.13", + "semver 1.0.14", ] [[package]] @@ -2577,7 +2785,7 @@ dependencies = [ "axum-server", "base64", "chrono", - "futures", + "futures 0.3.24", "futures-rustls", "http-types", "log", @@ -2591,8 +2799,8 @@ dependencies = [ "smol", "thiserror", "tokio", - "tokio-util", - "url", + "tokio-util 0.7.4", + "url 2.3.0", "webpki-roots 0.21.1", "x509-parser", ] @@ -2701,9 +2909,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" [[package]] name = "semver-parser" @@ -2748,7 +2956,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7715380eec75f029a4ef7de39a9200e0a63823176b759d055b613f5a87df6a6" dependencies = [ - "percent-encoding", + "percent-encoding 2.2.0", "serde", "thiserror", ] @@ -2786,13 +2994,24 @@ version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "block-buffer", - "cfg-if", + "block-buffer 0.9.0", + "cfg-if 1.0.0", "cpufeatures", - "digest", + "digest 0.9.0", "opaque-debug", ] +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.5", +] + [[package]] name = "signal-hook" version = "0.3.14" @@ -3016,7 +3235,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "fastrand", "libc", "redox_syscall", @@ -3035,24 +3254,24 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" [[package]] name = "thiserror" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1b05ca9d106ba7d2e31a9dab4a64e7be2cce415321966ea3132c49a656e252" +checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8f2591983642de85c921015f3f070c665a197ed69e417af436115e3a1407487" +checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" dependencies = [ "proc-macro2", "quote", @@ -3128,9 +3347,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.21.0" +version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89797afd69d206ccd11fb0ea560a44bbb87731d020670e79416d442919257d42" +checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95" dependencies = [ "autocfg 1.1.0", "bytes", @@ -3188,6 +3407,20 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-util" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.4" @@ -3203,6 +3436,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + [[package]] name = "tower" version = "0.4.13" @@ -3256,7 +3498,7 @@ version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "log", "pin-project-lite", "tracing-core", @@ -3300,9 +3542,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" [[package]] name = "unicode-normalization" @@ -3315,15 +3557,15 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "unicode-xid" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "unindent" @@ -3347,6 +3589,17 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "url" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +dependencies = [ + "idna 0.1.5", + "matches", + "percent-encoding 1.0.1", +] + [[package]] name = "url" version = "2.3.0" @@ -3354,8 +3607,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22fe195a4f217c25b25cb5058ced57059824a678474874038dc88d211bf508d3" dependencies = [ "form_urlencoded", - "idna", - "percent-encoding", + "idna 0.2.1", + "percent-encoding 2.2.0", "serde", ] @@ -3428,19 +3681,19 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" dependencies = [ "bumpalo", "log", @@ -3453,11 +3706,11 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -3465,9 +3718,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3475,9 +3728,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", @@ -3488,15 +3741,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "web-sys" -version = "0.3.59" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 47262900dd..29aa63655e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,10 @@ tower-http = { version = "0.3.3", features = ["cors"] } [dev-dependencies] executable-path = "1.0.0" hex = "0.4.3" +jsonrpc-core = "18.0.0" +jsonrpc-core-client = "18.0.0" +jsonrpc-derive = "18.0.0" +jsonrpc-http-server = "18.0.0" log = "0.4.14" nix = "0.24.1" pretty_assertions = "1.2.1" diff --git a/build.rs b/build.rs deleted file mode 100644 index 69f8dfe33e..0000000000 --- a/build.rs +++ /dev/null @@ -1,32 +0,0 @@ -use { - pulldown_cmark::{html, Parser}, - std::{env, ffi::OsStr, fs, path::Path}, -}; - -fn main() { - println!("cargo:rerun-if-changed=markdown"); - - for result in fs::read_dir("markdown").unwrap() { - let entry = result.unwrap(); - let path = entry.path(); - - if path.extension() != Some(OsStr::new("md")) { - continue; - } - - let input = fs::read_to_string(&path).unwrap(); - - let parser = Parser::new(&input); - - let mut output = String::new(); - html::push_html(&mut output, parser); - - fs::write( - Path::new(&env::var("OUT_DIR").unwrap()) - .join(path.file_stem().unwrap()) - .with_extension("html"), - output, - ) - .unwrap(); - } -} diff --git a/docs/config.toml b/docs/config.toml new file mode 100644 index 0000000000..b377572efc --- /dev/null +++ b/docs/config.toml @@ -0,0 +1,8 @@ +base_url = "https://docs.ordinals.com" +compile_sass = false +build_search_index = false + +[markdown] +highlight_code = false + +[extra] diff --git a/markdown/bounties.md b/docs/content/bounties.md similarity index 98% rename from markdown/bounties.md rename to docs/content/bounties.md index d71597527a..1d94cbac83 100644 --- a/markdown/bounties.md +++ b/docs/content/bounties.md @@ -1,5 +1,6 @@ -Ordinal Bounties -================ ++++ +title = "Bounties" ++++ Bounty 2 -------- diff --git a/markdown/faq.md b/docs/content/faq.md similarity index 99% rename from markdown/faq.md rename to docs/content/faq.md index 39173d07e1..448225ee99 100644 --- a/markdown/faq.md +++ b/docs/content/faq.md @@ -1,6 +1,6 @@ -Ordinal FAQ -=========== - ++++ +title = "FAQ" ++++ How many ordinals will there be? -------------------------------- diff --git a/docs/static/CNAME b/docs/static/CNAME new file mode 100644 index 0000000000..03bfd32778 --- /dev/null +++ b/docs/static/CNAME @@ -0,0 +1 @@ +docs.ordinals.com diff --git a/docs/static/index.css b/docs/static/index.css new file mode 120000 index 0000000000..df4aecbb0c --- /dev/null +++ b/docs/static/index.css @@ -0,0 +1 @@ +../../static/index.css \ No newline at end of file diff --git a/docs/static/modern-normalize.css b/docs/static/modern-normalize.css new file mode 120000 index 0000000000..a93b2fd08a --- /dev/null +++ b/docs/static/modern-normalize.css @@ -0,0 +1 @@ +../../static/modern-normalize.css \ No newline at end of file diff --git a/docs/templates/base.html b/docs/templates/base.html new file mode 100644 index 0000000000..c17504cd0f --- /dev/null +++ b/docs/templates/base.html @@ -0,0 +1,15 @@ + + + + + + + Ordinals {% if page.title %} | {{ page.title }} {% endif %} + + + + +{% block content %} +{% endblock %} + + diff --git a/docs/templates/index.html b/docs/templates/index.html new file mode 100644 index 0000000000..5da77f35b5 --- /dev/null +++ b/docs/templates/index.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% block content %} + +{% endblock content %} diff --git a/docs/templates/page.html b/docs/templates/page.html new file mode 100644 index 0000000000..80424c428e --- /dev/null +++ b/docs/templates/page.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block content %} +

{{ page.title }}

+

{{ page.date }}

+{{ page.content | safe }} +{% endblock content %} diff --git a/justfile b/justfile index 5a4cc09b90..dfa245172f 100644 --- a/justfile +++ b/justfile @@ -99,3 +99,6 @@ flamegraph: benchmark dir=`git branch --show-current`: ./bin/benchmark '{{dir}}' + +serve-docs: + cd docs && zola serve --open diff --git a/src/main.rs b/src/main.rs index 27e1b03722..07699116dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,23 +69,11 @@ use { }; #[cfg(test)] -use regex::Regex; +#[macro_use] +mod test; #[cfg(test)] -macro_rules! assert_regex_match { - ($string:expr, $pattern:expr $(,)?) => { - let pattern: &'static str = $pattern; - let regex = Regex::new(&format!("^(?s){}$", pattern)).unwrap(); - let string = $string; - - if !regex.is_match(string.as_ref()) { - panic!( - "Regex:\n\n{}\n\n…did not match string:\n\n{}", - regex, string - ); - } - }; -} +use self::test::*; mod arguments; mod blocktime; diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 9ffb229652..8976236eb9 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -132,6 +132,7 @@ impl Server { self.spawn(&router, &handle, None)?, self.spawn(&router, &handle, self.acceptor(&options)?)? ); + http_result.and(https_result)?.transpose()?; Ok(()) @@ -475,37 +476,119 @@ impl Server { } async fn faq() -> impl IntoResponse { - StaticHtml { - title: "Ordinal FAQ", - html: include_str!(concat!(env!("OUT_DIR"), "/faq.html")), - } - .page() - .into_response() + Redirect::to("https://docs.ordinals.com/faq/") } async fn bounties() -> impl IntoResponse { - StaticHtml { - title: "Ordinal Bounties", - html: include_str!(concat!(env!("OUT_DIR"), "/bounties.html")), - } - .page() - .into_response() + Redirect::to("https://docs.ordinals.com/bounties/") } } #[cfg(test)] mod tests { - use super::*; - - fn parse_server_args(args: &str) -> Server { - match Arguments::try_parse_from( - ["ord", "server"] - .iter() - .cloned() - .chain(args.split_whitespace()), - ) { + use { + super::*, + jsonrpc_core::IoHandler, + jsonrpc_derive::rpc, + jsonrpc_http_server::{CloseHandle, ServerBuilder}, + std::net::TcpListener, + tempfile::TempDir, + }; + + #[rpc] + pub trait BitcoinRpc { + fn getblockhash(&self, height: usize) -> Result; + } + + struct BitcoinRpcServer; + + impl BitcoinRpc for BitcoinRpcServer { + fn getblockhash(&self, _height: usize) -> Result { + Err(jsonrpc_core::Error::new( + jsonrpc_core::types::error::ErrorCode::ServerError(-8), + )) + } + } + + struct TestServer { + close_handle: Option, + #[allow(unused)] + tempdir: TempDir, + port: u16, + } + + impl TestServer { + fn new() -> Self { + let mut io = IoHandler::default(); + io.extend_with(BitcoinRpcServer.to_delegate()); + + let rpc_server = ServerBuilder::new(io) + .threads(1) + .start_http(&"127.0.0.1:0".parse().unwrap()) + .unwrap(); + + let rpc_port = rpc_server.address().port(); + let close_handle = rpc_server.close_handle(); + + thread::spawn(|| rpc_server.wait()); + + let tempdir = TempDir::new().unwrap(); + + let cookiefile = tempdir.path().join("cookie"); + + fs::write(&cookiefile, "username:password").unwrap(); + + let port = TcpListener::bind("127.0.0.1:0") + .unwrap() + .local_addr() + .unwrap() + .port(); + + let (options, server) = parse_server_args(&format!( + "ord --rpc-url http://127.0.0.1:{} --cookie-file {} --data-dir {} server --http-port {}", + rpc_port, + cookiefile.to_str().unwrap(), + tempdir.path().to_str().unwrap(), + port, + )); + + thread::spawn(|| server.run(options).unwrap()); + + for i in 0.. { + match reqwest::blocking::get(&format!("http://127.0.0.1:{port}/status")) { + Ok(_) => break, + Err(err) => { + if i == 400 { + panic!("Server failed to start: {err}"); + } + } + } + + thread::sleep(Duration::from_millis(25)); + } + + Self { + port, + close_handle: Some(close_handle), + tempdir, + } + } + + fn url_with_path(&self, path: &str) -> String { + format!("http://127.0.0.1:{}/{path}", self.port) + } + } + + impl Drop for TestServer { + fn drop(&mut self) { + self.close_handle.take().unwrap().close(); + } + } + + fn parse_server_args(args: &str) -> (Options, Server) { + match Arguments::try_parse_from(args.split_whitespace()) { Ok(arguments) => match arguments.subcommand { - Subcommand::Server(server) => server, + Subcommand::Server(server) => (arguments.options, server), subcommand => panic!("Unexpected subcommand: {subcommand:?}"), }, Err(err) => panic!("Error parsing arguments: {err}"), @@ -515,24 +598,25 @@ mod tests { #[test] fn http_and_https_port_dont_conflict() { parse_server_args( - "--http-port 0 --https-port 0 --acme-cache foo --acme-contact bar --acme-domain baz", + "ord server --http-port 0 --https-port 0 --acme-cache foo --acme-contact bar --acme-domain baz", ); } #[test] fn http_port_defaults_to_80() { - assert_eq!(parse_server_args("").http_port(), Some(80)); + assert_eq!(parse_server_args("ord server").1.http_port(), Some(80)); } #[test] fn https_port_defaults_to_none() { - assert_eq!(parse_server_args("").https_port(), None); + assert_eq!(parse_server_args("ord server").1.https_port(), None); } #[test] fn https_sets_https_port_to_443() { assert_eq!( - parse_server_args("--https --acme-cache foo --acme-contact bar --acme-domain baz") + parse_server_args("ord server --https --acme-cache foo --acme-contact bar --acme-domain baz") + .1 .https_port(), Some(443) ); @@ -541,7 +625,8 @@ mod tests { #[test] fn https_disables_http() { assert_eq!( - parse_server_args("--https --acme-cache foo --acme-contact bar --acme-domain baz") + parse_server_args("ord server --https --acme-cache foo --acme-contact bar --acme-domain baz") + .1 .http_port(), None ); @@ -550,8 +635,11 @@ mod tests { #[test] fn https_port_disables_http() { assert_eq!( - parse_server_args("--https-port 433 --acme-cache foo --acme-contact bar --acme-domain baz") - .http_port(), + parse_server_args( + "ord server --https-port 433 --acme-cache foo --acme-contact bar --acme-domain baz" + ) + .1 + .http_port(), None ); } @@ -559,8 +647,11 @@ mod tests { #[test] fn https_port_sets_https_port() { assert_eq!( - parse_server_args("--https-port 1000 --acme-cache foo --acme-contact bar --acme-domain baz") - .https_port(), + parse_server_args( + "ord server --https-port 1000 --acme-cache foo --acme-contact bar --acme-domain baz" + ) + .1 + .https_port(), Some(1000) ); } @@ -568,8 +659,11 @@ mod tests { #[test] fn http_with_https_leaves_http_enabled() { assert_eq!( - parse_server_args("--https --http --acme-cache foo --acme-contact bar --acme-domain baz") - .http_port(), + parse_server_args( + "ord server --https --http --acme-cache foo --acme-contact bar --acme-domain baz" + ) + .1 + .http_port(), Some(80) ); } @@ -577,8 +671,11 @@ mod tests { #[test] fn http_with_https_leaves_https_enabled() { assert_eq!( - parse_server_args("--https --http --acme-cache foo --acme-contact bar --acme-domain baz") - .https_port(), + parse_server_args( + "ord server --https --http --acme-cache foo --acme-contact bar --acme-domain baz" + ) + .1 + .https_port(), Some(443) ); } @@ -654,4 +751,42 @@ mod tests { &["example.com"] ); } + + #[test] + fn bounties_redirects_to_docs_site() { + let test_server = TestServer::new(); + + let response = reqwest::blocking::Client::builder() + .redirect(reqwest::redirect::Policy::none()) + .build() + .unwrap() + .get(test_server.url_with_path("bounties")) + .send() + .unwrap(); + + assert_eq!(response.status(), StatusCode::SEE_OTHER); + assert_eq!( + response.headers().get(header::LOCATION).unwrap(), + "https://docs.ordinals.com/bounties/" + ); + } + + #[test] + fn faq_redirects_to_docs_site() { + let test_server = TestServer::new(); + + let response = reqwest::blocking::Client::builder() + .redirect(reqwest::redirect::Policy::none()) + .build() + .unwrap() + .get(test_server.url_with_path("faq")) + .send() + .unwrap(); + + assert_eq!(response.status(), StatusCode::SEE_OTHER); + assert_eq!( + response.headers().get(header::LOCATION).unwrap(), + "https://docs.ordinals.com/faq/" + ); + } } diff --git a/src/test.rs b/src/test.rs new file mode 100644 index 0000000000..298b7e3f54 --- /dev/null +++ b/src/test.rs @@ -0,0 +1,16 @@ +pub(crate) use regex::Regex; + +macro_rules! assert_regex_match { + ($string:expr, $pattern:expr $(,)?) => { + let pattern: &'static str = $pattern; + let regex = Regex::new(&format!("^(?s){}$", pattern)).unwrap(); + let string = $string; + + if !regex.is_match(string.as_ref()) { + panic!( + "Regex:\n\n{}\n\n…did not match string:\n\n{}", + regex, string + ); + } + }; +} diff --git a/templates/home.html b/templates/home.html index 7f1e14dd5e..9590cb3241 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,8 +1,8 @@

Ordinals