diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d328577..5af0cd4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,42 +18,43 @@ env: jobs: test_dev: runs-on: ubuntu-latest + # see capnp-runner.dockerfile + container: ghcr.io/jonoprest/capnp-runner:latest steps: - - uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@v2 - - name: Install Dependencies - run: | - export DEBIAN_FRONTEND=noninteractive - sudo apt-get install -y capnproto libcapnp-dev - - name: Build - run: cargo build - - name: Test - run: cargo test + - uses: actions/checkout@v3 + # selecting a toolchain either by action or manual `rustup` calls should happen + # before the plugin, as the cache uses the current rustc version as its cache key + - run: rustup toolchain install stable + - uses: Swatinem/rust-cache@v2 + - name: Build + run: cargo build + - name: Test + run: cargo test + - name: Check capnp schema should match the generated code + working-directory: ./hypersync-net-types + run: | + make capnp-build + git diff --exit-code test_release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@v2 - - name: Install Dependencies - run: | - export DEBIAN_FRONTEND=noninteractive - sudo apt-get install -y capnproto libcapnp-dev - - name: Build - run: cargo build --release - - name: Test - run: cargo test --release + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - name: Build + run: cargo build --release + - name: Test + run: cargo test --release lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@v2 - - name: Install Dependencies - run: | - export DEBIAN_FRONTEND=noninteractive - sudo apt-get install -y capnproto libcapnp-dev - - name: Rustfmt - run: cargo fmt --check - - name: Clippy - run: cargo clippy -- -Dwarnings \ No newline at end of file + - uses: actions/checkout@v3 + # selecting a toolchain either by action or manual `rustup` calls should happen + # before the plugin, as the cache uses the current rustc version as its cache key + - run: rustup toolchain install stable + - uses: Swatinem/rust-cache@v2 + - name: Rustfmt + run: cargo fmt --check + - name: Clippy + run: cargo clippy -- -Dwarnings diff --git a/README.md b/README.md index c8d32ee..c4007fb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CI](https://github.com/enviodev/hypersync-client-rust/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/enviodev/hypersync-client-rust/actions/workflows/ci.yaml) - Crates.io version @@ -12,7 +12,7 @@ Rust crate for [Envio's](https://envio.dev/) HyperSync client. ### Dependencies -Need to install capnproto tool in order to build the library. +In order to update the capnp schema on hypersync-net-types, you will need to install the `capnproto` tool. #### Linux @@ -31,3 +31,14 @@ choco install capnproto ```bash brew install capnp ``` + +## Building + +To build the schema, run the following command: + +```bash +cd hypersync-net-types +make capnp-build +``` + +This triggers the build script in hypersync-net-types, which will generate the `hypersync_net_types_capnp.rs` file in the `src` directory. diff --git a/capnp-runner.dockerfile b/capnp-runner.dockerfile new file mode 100644 index 0000000..1b8d268 --- /dev/null +++ b/capnp-runner.dockerfile @@ -0,0 +1,33 @@ +# This Dockerfile is used for ci to have the latest version of Cap'n Proto (1.1.0) +# built from source. Since ubuntu package manager is not up to date. + +# Start with a base image +FROM ubuntu:22.04 + +# Set non-interactive mode to prevent prompts during installation +ENV DEBIAN_FRONTEND=noninteractive + +# Install dependencies +RUN apt update && apt install -y \ + build-essential \ + cmake \ + curl \ + git \ + sudo \ + && rm -rf /var/lib/apt/lists/* + +# Download and install Cap'n Proto 1.1.0 +WORKDIR /opt +RUN curl -O https://capnproto.org/capnproto-c++-1.1.0.tar.gz && \ + tar zxf capnproto-c++-1.1.0.tar.gz && \ + cd capnproto-c++-1.1.0 && \ + ./configure && \ + make -j$(nproc) check && \ + sudo make install && \ + cd .. && rm -rf capnproto-c++-1.1.0 capnproto-c++-1.1.0.tar.gz + +# Set environment variables +ENV PATH="/usr/local/bin:$PATH" + +# Keep the container running +CMD ["tail", "-f", "/dev/null"] diff --git a/hypersync-client/src/stream.rs b/hypersync-client/src/stream.rs index 958e1d3..e20b413 100644 --- a/hypersync-client/src/stream.rs +++ b/hypersync-client/src/stream.rs @@ -169,7 +169,7 @@ pub async fn stream_arrow( let x = x as u32; let batch_size = cmp::max((x as f64 * ratio) as u64, min_batch_size); - let step = batch_size | u64::from(next_generation) << 32; + let step = batch_size | (u64::from(next_generation) << 32); Some(step) }) .ok(); @@ -180,7 +180,7 @@ pub async fn stream_arrow( let x = x as u32; let batch_size = cmp::min((x as f64 * ratio) as u64, max_batch_size); - let step = batch_size | u64::from(next_generation) << 32; + let step = batch_size | (u64::from(next_generation) << 32); Some(step) }) .ok(); diff --git a/hypersync-format/src/types/bloom_filter_wrapper.rs b/hypersync-format/src/types/bloom_filter_wrapper.rs index 7c6219f..fcb8e37 100644 --- a/hypersync-format/src/types/bloom_filter_wrapper.rs +++ b/hypersync-format/src/types/bloom_filter_wrapper.rs @@ -72,7 +72,7 @@ impl<'de> Deserialize<'de> for FilterWrapper { { struct FilterWrapperVisitor; - impl<'de> Visitor<'de> for FilterWrapperVisitor { + impl Visitor<'_> for FilterWrapperVisitor { type Value = FilterWrapper; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/hypersync-format/src/types/data.rs b/hypersync-format/src/types/data.rs index dc63b7f..c2ce458 100644 --- a/hypersync-format/src/types/data.rs +++ b/hypersync-format/src/types/data.rs @@ -38,7 +38,7 @@ impl From<[u8; N]> for Data { struct DataVisitor; -impl<'de> Visitor<'de> for DataVisitor { +impl Visitor<'_> for DataVisitor { type Value = Data; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/hypersync-format/src/types/fixed_size_data.rs b/hypersync-format/src/types/fixed_size_data.rs index fc94541..8e16281 100644 --- a/hypersync-format/src/types/fixed_size_data.rs +++ b/hypersync-format/src/types/fixed_size_data.rs @@ -135,7 +135,7 @@ impl fmt::Display for FixedSizeData { struct FixedSizeDataVisitor; -impl<'de, const N: usize> Visitor<'de> for FixedSizeDataVisitor { +impl Visitor<'_> for FixedSizeDataVisitor { type Value = FixedSizeData; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -191,6 +191,8 @@ impl fmt::Debug for FixedSizeData { #[cfg(test)] mod tests { type FixedSizeData = super::FixedSizeData<4>; + type FSD4 = FixedSizeData; + use derive_more::FromStr; use hex_literal::hex; use serde_test::{assert_tokens, Token}; diff --git a/hypersync-format/src/types/quantity.rs b/hypersync-format/src/types/quantity.rs index 2a5b8fd..ee54a86 100644 --- a/hypersync-format/src/types/quantity.rs +++ b/hypersync-format/src/types/quantity.rs @@ -91,7 +91,7 @@ impl From<[u8; N]> for Quantity { struct QuantityVisitor; -impl<'de> Visitor<'de> for QuantityVisitor { +impl Visitor<'_> for QuantityVisitor { type Value = Quantity; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/hypersync-format/src/types/transaction_status.rs b/hypersync-format/src/types/transaction_status.rs index 4363175..cb13508 100644 --- a/hypersync-format/src/types/transaction_status.rs +++ b/hypersync-format/src/types/transaction_status.rs @@ -53,7 +53,7 @@ impl TransactionStatus { struct TransactionStatusVisitor; -impl<'de> Visitor<'de> for TransactionStatusVisitor { +impl Visitor<'_> for TransactionStatusVisitor { type Value = TransactionStatus; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/hypersync-format/src/types/transaction_type.rs b/hypersync-format/src/types/transaction_type.rs index 6e8001e..0627e6b 100644 --- a/hypersync-format/src/types/transaction_type.rs +++ b/hypersync-format/src/types/transaction_type.rs @@ -25,7 +25,7 @@ pub struct TransactionType(pub u8); struct TransactionTypeVisitor; -impl<'de> Visitor<'de> for TransactionTypeVisitor { +impl Visitor<'_> for TransactionTypeVisitor { type Value = TransactionType; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/hypersync-format/src/types/uint.rs b/hypersync-format/src/types/uint.rs index 1d69bc0..88c91c6 100644 --- a/hypersync-format/src/types/uint.rs +++ b/hypersync-format/src/types/uint.rs @@ -59,7 +59,7 @@ impl From for ethabi::ethereum_types::U256 { struct UIntVisitor; -impl<'de> Visitor<'de> for UIntVisitor { +impl Visitor<'_> for UIntVisitor { type Value = UInt; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/hypersync-format/src/types/util.rs b/hypersync-format/src/types/util.rs index 9d2b82e..3c2e352 100644 --- a/hypersync-format/src/types/util.rs +++ b/hypersync-format/src/types/util.rs @@ -1,5 +1,5 @@ pub fn decode_hex(hex: &str) -> Result, faster_hex::Error> { - let len = hex.as_bytes().len(); + let len = hex.len(); let mut dst = vec![0; len / 2]; faster_hex::hex_decode(hex.as_bytes(), &mut dst)?; diff --git a/hypersync-net-types/Cargo.toml b/hypersync-net-types/Cargo.toml index f4f1a91..2cf8e5c 100644 --- a/hypersync-net-types/Cargo.toml +++ b/hypersync-net-types/Cargo.toml @@ -11,6 +11,3 @@ serde = { version = "1", features = ["derive"] } arrayvec = { version = "0.7", features = ["serde"] } hypersync-format = { path = "../hypersync-format", version = "0.4" } - -[build-dependencies] -capnpc = "0.19" diff --git a/hypersync-net-types/README.md b/hypersync-net-types/README.md new file mode 100644 index 0000000..6e4a1a5 --- /dev/null +++ b/hypersync-net-types/README.md @@ -0,0 +1,19 @@ +# hypersync-net-types + +This crate contains the capnp schema for the hypersync network protocol. + +## Building + +To build the schema, run the following command: + +```bash +make capnp-build +``` + +This will generate the `hypersync_net_types_capnp.rs` file in the `src` directory. + +The build script will not run on every build, so you will need to run it manually if you make changes to the schema. + +The ci tests will fail if the schema is not up to date. + +This is to avoid the need to have a capnp compiler installed on the consumers of this crate. diff --git a/hypersync-net-types/build.rs b/hypersync-net-types/build.rs deleted file mode 100644 index f8902cb..0000000 --- a/hypersync-net-types/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - capnpc::CompilerCommand::new() - .file("hypersync_net_types.capnp") - .run() - .expect("compiling schema"); -} diff --git a/hypersync-net-types/makefile b/hypersync-net-types/makefile new file mode 100644 index 0000000..7ef43e4 --- /dev/null +++ b/hypersync-net-types/makefile @@ -0,0 +1,8 @@ +.PHONY: capnp-build + +capnp-build: + # Ensure we are building with the same capnp (1.1.0) in all environments + capnp --version | grep -q "1.1.0" + cargo install capnpc + capnpc -orust:src hypersync_net_types.capnp + rustfmt -- src/hypersync_net_types_capnp.rs diff --git a/hypersync-net-types/src/hypersync_net_types_capnp.rs b/hypersync-net-types/src/hypersync_net_types_capnp.rs new file mode 100644 index 0000000..ac5efcf --- /dev/null +++ b/hypersync-net-types/src/hypersync_net_types_capnp.rs @@ -0,0 +1,1330 @@ +// @generated by the capnpc-rust plugin to the Cap'n Proto schema compiler. +// DO NOT EDIT. +// source: hypersync_net_types.capnp + +pub mod query_response_data { + #[derive(Copy, Clone)] + pub struct Owned(()); + impl ::capnp::introspect::Introspect for Owned { + fn introspect() -> ::capnp::introspect::Type { + ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }) + .into() + } + } + impl ::capnp::traits::Owned for Owned { + type Reader<'a> = Reader<'a>; + type Builder<'a> = Builder<'a>; + } + impl ::capnp::traits::OwnedStruct for Owned { + type Reader<'a> = Reader<'a>; + type Builder<'a> = Builder<'a>; + } + impl ::capnp::traits::Pipelined for Owned { + type Pipeline = Pipeline; + } + + pub struct Reader<'a> { + reader: ::capnp::private::layout::StructReader<'a>, + } + impl ::core::marker::Copy for Reader<'_> {} + impl ::core::clone::Clone for Reader<'_> { + fn clone(&self) -> Self { + *self + } + } + + impl ::capnp::traits::HasTypeId for Reader<'_> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl<'a> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a> { + fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { + Self { reader } + } + } + + impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { + fn from(reader: Reader<'a>) -> Self { + Self::Struct(::capnp::dynamic_struct::Reader::new( + reader.reader, + ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }), + )) + } + } + + impl ::core::fmt::Debug for Reader<'_> { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::result::Result<(), ::core::fmt::Error> { + core::fmt::Debug::fmt( + &::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), + f, + ) + } + } + + impl<'a> ::capnp::traits::FromPointerReader<'a> for Reader<'a> { + fn get_from_pointer( + reader: &::capnp::private::layout::PointerReader<'a>, + default: ::core::option::Option<&'a [::capnp::Word]>, + ) -> ::capnp::Result { + ::core::result::Result::Ok(reader.get_struct(default)?.into()) + } + } + + impl<'a> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a> { + fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> { + self.reader + } + } + + impl<'a> ::capnp::traits::Imbue<'a> for Reader<'a> { + fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) { + self.reader + .imbue(::capnp::private::layout::CapTableReader::Plain(cap_table)) + } + } + + impl<'a> Reader<'a> { + pub fn reborrow(&self) -> Reader<'_> { + Self { ..*self } + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn get_blocks(self) -> ::capnp::Result<::capnp::data::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer( + &self.reader.get_pointer_field(0), + ::core::option::Option::None, + ) + } + #[inline] + pub fn has_blocks(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_transactions(self) -> ::capnp::Result<::capnp::data::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer( + &self.reader.get_pointer_field(1), + ::core::option::Option::None, + ) + } + #[inline] + pub fn has_transactions(&self) -> bool { + !self.reader.get_pointer_field(1).is_null() + } + #[inline] + pub fn get_logs(self) -> ::capnp::Result<::capnp::data::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer( + &self.reader.get_pointer_field(2), + ::core::option::Option::None, + ) + } + #[inline] + pub fn has_logs(&self) -> bool { + !self.reader.get_pointer_field(2).is_null() + } + #[inline] + pub fn get_traces(self) -> ::capnp::Result<::capnp::data::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer( + &self.reader.get_pointer_field(3), + ::core::option::Option::None, + ) + } + #[inline] + pub fn has_traces(&self) -> bool { + !self.reader.get_pointer_field(3).is_null() + } + } + + pub struct Builder<'a> { + builder: ::capnp::private::layout::StructBuilder<'a>, + } + impl ::capnp::traits::HasStructSize for Builder<'_> { + const STRUCT_SIZE: ::capnp::private::layout::StructSize = + ::capnp::private::layout::StructSize { + data: 0, + pointers: 4, + }; + } + impl ::capnp::traits::HasTypeId for Builder<'_> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl<'a> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a> { + fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { + Self { builder } + } + } + + impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { + fn from(builder: Builder<'a>) -> Self { + Self::Struct(::capnp::dynamic_struct::Builder::new( + builder.builder, + ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }), + )) + } + } + + impl<'a> ::capnp::traits::ImbueMut<'a> for Builder<'a> { + fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) { + self.builder + .imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table)) + } + } + + impl<'a> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a> { + fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self { + builder + .init_struct(::STRUCT_SIZE) + .into() + } + fn get_from_pointer( + builder: ::capnp::private::layout::PointerBuilder<'a>, + default: ::core::option::Option<&'a [::capnp::Word]>, + ) -> ::capnp::Result { + ::core::result::Result::Ok( + builder + .get_struct( + ::STRUCT_SIZE, + default, + )? + .into(), + ) + } + } + + impl ::capnp::traits::SetterInput for Reader<'_> { + fn set_pointer_builder( + mut pointer: ::capnp::private::layout::PointerBuilder<'_>, + value: Self, + canonicalize: bool, + ) -> ::capnp::Result<()> { + pointer.set_struct(&value.reader, canonicalize) + } + } + + impl<'a> Builder<'a> { + pub fn into_reader(self) -> Reader<'a> { + self.builder.into_reader().into() + } + pub fn reborrow(&mut self) -> Builder<'_> { + Builder { + builder: self.builder.reborrow(), + } + } + pub fn reborrow_as_reader(&self) -> Reader<'_> { + self.builder.as_reader().into() + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() + } + #[inline] + pub fn get_blocks(self) -> ::capnp::Result<::capnp::data::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer( + self.builder.get_pointer_field(0), + ::core::option::Option::None, + ) + } + #[inline] + pub fn set_blocks(&mut self, value: ::capnp::data::Reader<'_>) { + self.builder.reborrow().get_pointer_field(0).set_data(value); + } + #[inline] + pub fn init_blocks(self, size: u32) -> ::capnp::data::Builder<'a> { + self.builder.get_pointer_field(0).init_data(size) + } + #[inline] + pub fn has_blocks(&self) -> bool { + !self.builder.is_pointer_field_null(0) + } + #[inline] + pub fn get_transactions(self) -> ::capnp::Result<::capnp::data::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer( + self.builder.get_pointer_field(1), + ::core::option::Option::None, + ) + } + #[inline] + pub fn set_transactions(&mut self, value: ::capnp::data::Reader<'_>) { + self.builder.reborrow().get_pointer_field(1).set_data(value); + } + #[inline] + pub fn init_transactions(self, size: u32) -> ::capnp::data::Builder<'a> { + self.builder.get_pointer_field(1).init_data(size) + } + #[inline] + pub fn has_transactions(&self) -> bool { + !self.builder.is_pointer_field_null(1) + } + #[inline] + pub fn get_logs(self) -> ::capnp::Result<::capnp::data::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer( + self.builder.get_pointer_field(2), + ::core::option::Option::None, + ) + } + #[inline] + pub fn set_logs(&mut self, value: ::capnp::data::Reader<'_>) { + self.builder.reborrow().get_pointer_field(2).set_data(value); + } + #[inline] + pub fn init_logs(self, size: u32) -> ::capnp::data::Builder<'a> { + self.builder.get_pointer_field(2).init_data(size) + } + #[inline] + pub fn has_logs(&self) -> bool { + !self.builder.is_pointer_field_null(2) + } + #[inline] + pub fn get_traces(self) -> ::capnp::Result<::capnp::data::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer( + self.builder.get_pointer_field(3), + ::core::option::Option::None, + ) + } + #[inline] + pub fn set_traces(&mut self, value: ::capnp::data::Reader<'_>) { + self.builder.reborrow().get_pointer_field(3).set_data(value); + } + #[inline] + pub fn init_traces(self, size: u32) -> ::capnp::data::Builder<'a> { + self.builder.get_pointer_field(3).init_data(size) + } + #[inline] + pub fn has_traces(&self) -> bool { + !self.builder.is_pointer_field_null(3) + } + } + + pub struct Pipeline { + _typeless: ::capnp::any_pointer::Pipeline, + } + impl ::capnp::capability::FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { + Self { + _typeless: typeless, + } + } + } + impl Pipeline {} + mod _private { + pub static ENCODED_NODE: [::capnp::Word; 81] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(49, 157, 62, 151, 169, 39, 204, 137), + ::capnp::word(26, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(197, 128, 248, 24, 106, 165, 137, 146), + ::capnp::word(4, 0, 7, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 98, 1, 0, 0), + ::capnp::word(41, 0, 0, 0, 7, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(37, 0, 0, 0, 231, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(104, 121, 112, 101, 114, 115, 121, 110), + ::capnp::word(99, 95, 110, 101, 116, 95, 116, 121), + ::capnp::word(112, 101, 115, 46, 99, 97, 112, 110), + ::capnp::word(112, 58, 81, 117, 101, 114, 121, 82), + ::capnp::word(101, 115, 112, 111, 110, 115, 101, 68), + ::capnp::word(97, 116, 97, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(16, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(97, 0, 0, 0, 58, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(92, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(104, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(1, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(101, 0, 0, 0, 106, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(100, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(112, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(2, 0, 0, 0, 2, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 2, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(109, 0, 0, 0, 42, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(104, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(116, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(3, 0, 0, 0, 3, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 3, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(113, 0, 0, 0, 58, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(108, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(120, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(98, 108, 111, 99, 107, 115, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(116, 114, 97, 110, 115, 97, 99, 116), + ::capnp::word(105, 111, 110, 115, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(108, 111, 103, 115, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(116, 114, 97, 99, 101, 115, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ]; + pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { + match index { + 0 => <::capnp::data::Owned as ::capnp::introspect::Introspect>::introspect(), + 1 => <::capnp::data::Owned as ::capnp::introspect::Introspect>::introspect(), + 2 => <::capnp::data::Owned as ::capnp::introspect::Introspect>::introspect(), + 3 => <::capnp::data::Owned as ::capnp::introspect::Introspect>::introspect(), + _ => panic!("invalid field index {}", index), + } + } + pub fn get_annotation_types( + child_index: Option, + index: u32, + ) -> ::capnp::introspect::Type { + panic!("invalid annotation indices ({:?}, {}) ", child_index, index) + } + pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = + ::capnp::introspect::RawStructSchema { + encoded_node: &ENCODED_NODE, + nonunion_members: NONUNION_MEMBERS, + members_by_discriminant: MEMBERS_BY_DISCRIMINANT, + members_by_name: MEMBERS_BY_NAME, + }; + pub static NONUNION_MEMBERS: &[u16] = &[0, 1, 2, 3]; + pub static MEMBERS_BY_DISCRIMINANT: &[u16] = &[]; + pub static MEMBERS_BY_NAME: &[u16] = &[0, 2, 3, 1]; + pub const TYPE_ID: u64 = 0x89cc_27a9_973e_9d31; + } +} + +pub mod rollback_guard { + #[derive(Copy, Clone)] + pub struct Owned(()); + impl ::capnp::introspect::Introspect for Owned { + fn introspect() -> ::capnp::introspect::Type { + ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }) + .into() + } + } + impl ::capnp::traits::Owned for Owned { + type Reader<'a> = Reader<'a>; + type Builder<'a> = Builder<'a>; + } + impl ::capnp::traits::OwnedStruct for Owned { + type Reader<'a> = Reader<'a>; + type Builder<'a> = Builder<'a>; + } + impl ::capnp::traits::Pipelined for Owned { + type Pipeline = Pipeline; + } + + pub struct Reader<'a> { + reader: ::capnp::private::layout::StructReader<'a>, + } + impl ::core::marker::Copy for Reader<'_> {} + impl ::core::clone::Clone for Reader<'_> { + fn clone(&self) -> Self { + *self + } + } + + impl ::capnp::traits::HasTypeId for Reader<'_> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl<'a> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a> { + fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { + Self { reader } + } + } + + impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { + fn from(reader: Reader<'a>) -> Self { + Self::Struct(::capnp::dynamic_struct::Reader::new( + reader.reader, + ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }), + )) + } + } + + impl ::core::fmt::Debug for Reader<'_> { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::result::Result<(), ::core::fmt::Error> { + core::fmt::Debug::fmt( + &::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), + f, + ) + } + } + + impl<'a> ::capnp::traits::FromPointerReader<'a> for Reader<'a> { + fn get_from_pointer( + reader: &::capnp::private::layout::PointerReader<'a>, + default: ::core::option::Option<&'a [::capnp::Word]>, + ) -> ::capnp::Result { + ::core::result::Result::Ok(reader.get_struct(default)?.into()) + } + } + + impl<'a> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a> { + fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> { + self.reader + } + } + + impl<'a> ::capnp::traits::Imbue<'a> for Reader<'a> { + fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) { + self.reader + .imbue(::capnp::private::layout::CapTableReader::Plain(cap_table)) + } + } + + impl<'a> Reader<'a> { + pub fn reborrow(&self) -> Reader<'_> { + Self { ..*self } + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn get_hash(self) -> ::capnp::Result<::capnp::data::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer( + &self.reader.get_pointer_field(0), + ::core::option::Option::None, + ) + } + #[inline] + pub fn has_hash(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_block_number(self) -> u64 { + self.reader.get_data_field::(0) + } + #[inline] + pub fn get_timestamp(self) -> i64 { + self.reader.get_data_field::(1) + } + #[inline] + pub fn get_first_block_number(self) -> u64 { + self.reader.get_data_field::(2) + } + #[inline] + pub fn get_first_parent_hash(self) -> ::capnp::Result<::capnp::data::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer( + &self.reader.get_pointer_field(1), + ::core::option::Option::None, + ) + } + #[inline] + pub fn has_first_parent_hash(&self) -> bool { + !self.reader.get_pointer_field(1).is_null() + } + } + + pub struct Builder<'a> { + builder: ::capnp::private::layout::StructBuilder<'a>, + } + impl ::capnp::traits::HasStructSize for Builder<'_> { + const STRUCT_SIZE: ::capnp::private::layout::StructSize = + ::capnp::private::layout::StructSize { + data: 3, + pointers: 2, + }; + } + impl ::capnp::traits::HasTypeId for Builder<'_> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl<'a> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a> { + fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { + Self { builder } + } + } + + impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { + fn from(builder: Builder<'a>) -> Self { + Self::Struct(::capnp::dynamic_struct::Builder::new( + builder.builder, + ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }), + )) + } + } + + impl<'a> ::capnp::traits::ImbueMut<'a> for Builder<'a> { + fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) { + self.builder + .imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table)) + } + } + + impl<'a> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a> { + fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self { + builder + .init_struct(::STRUCT_SIZE) + .into() + } + fn get_from_pointer( + builder: ::capnp::private::layout::PointerBuilder<'a>, + default: ::core::option::Option<&'a [::capnp::Word]>, + ) -> ::capnp::Result { + ::core::result::Result::Ok( + builder + .get_struct( + ::STRUCT_SIZE, + default, + )? + .into(), + ) + } + } + + impl ::capnp::traits::SetterInput for Reader<'_> { + fn set_pointer_builder( + mut pointer: ::capnp::private::layout::PointerBuilder<'_>, + value: Self, + canonicalize: bool, + ) -> ::capnp::Result<()> { + pointer.set_struct(&value.reader, canonicalize) + } + } + + impl<'a> Builder<'a> { + pub fn into_reader(self) -> Reader<'a> { + self.builder.into_reader().into() + } + pub fn reborrow(&mut self) -> Builder<'_> { + Builder { + builder: self.builder.reborrow(), + } + } + pub fn reborrow_as_reader(&self) -> Reader<'_> { + self.builder.as_reader().into() + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() + } + #[inline] + pub fn get_hash(self) -> ::capnp::Result<::capnp::data::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer( + self.builder.get_pointer_field(0), + ::core::option::Option::None, + ) + } + #[inline] + pub fn set_hash(&mut self, value: ::capnp::data::Reader<'_>) { + self.builder.reborrow().get_pointer_field(0).set_data(value); + } + #[inline] + pub fn init_hash(self, size: u32) -> ::capnp::data::Builder<'a> { + self.builder.get_pointer_field(0).init_data(size) + } + #[inline] + pub fn has_hash(&self) -> bool { + !self.builder.is_pointer_field_null(0) + } + #[inline] + pub fn get_block_number(self) -> u64 { + self.builder.get_data_field::(0) + } + #[inline] + pub fn set_block_number(&mut self, value: u64) { + self.builder.set_data_field::(0, value); + } + #[inline] + pub fn get_timestamp(self) -> i64 { + self.builder.get_data_field::(1) + } + #[inline] + pub fn set_timestamp(&mut self, value: i64) { + self.builder.set_data_field::(1, value); + } + #[inline] + pub fn get_first_block_number(self) -> u64 { + self.builder.get_data_field::(2) + } + #[inline] + pub fn set_first_block_number(&mut self, value: u64) { + self.builder.set_data_field::(2, value); + } + #[inline] + pub fn get_first_parent_hash(self) -> ::capnp::Result<::capnp::data::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer( + self.builder.get_pointer_field(1), + ::core::option::Option::None, + ) + } + #[inline] + pub fn set_first_parent_hash(&mut self, value: ::capnp::data::Reader<'_>) { + self.builder.reborrow().get_pointer_field(1).set_data(value); + } + #[inline] + pub fn init_first_parent_hash(self, size: u32) -> ::capnp::data::Builder<'a> { + self.builder.get_pointer_field(1).init_data(size) + } + #[inline] + pub fn has_first_parent_hash(&self) -> bool { + !self.builder.is_pointer_field_null(1) + } + } + + pub struct Pipeline { + _typeless: ::capnp::any_pointer::Pipeline, + } + impl ::capnp::capability::FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { + Self { + _typeless: typeless, + } + } + } + impl Pipeline {} + mod _private { + pub static ENCODED_NODE: [::capnp::Word; 99] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(75, 175, 253, 87, 239, 86, 125, 149), + ::capnp::word(26, 0, 0, 0, 1, 0, 3, 0), + ::capnp::word(197, 128, 248, 24, 106, 165, 137, 146), + ::capnp::word(2, 0, 7, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 66, 1, 0, 0), + ::capnp::word(37, 0, 0, 0, 7, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(33, 0, 0, 0, 31, 1, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(104, 121, 112, 101, 114, 115, 121, 110), + ::capnp::word(99, 95, 110, 101, 116, 95, 116, 121), + ::capnp::word(112, 101, 115, 46, 99, 97, 112, 110), + ::capnp::word(112, 58, 82, 111, 108, 108, 98, 97), + ::capnp::word(99, 107, 71, 117, 97, 114, 100, 0), + ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(20, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(125, 0, 0, 0, 42, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(120, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(132, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(1, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(129, 0, 0, 0, 98, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(128, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(140, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(2, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 2, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(137, 0, 0, 0, 82, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(136, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(148, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(3, 0, 0, 0, 2, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 3, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(145, 0, 0, 0, 138, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(148, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(160, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(4, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 4, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(157, 0, 0, 0, 130, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(156, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(168, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(104, 97, 115, 104, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(98, 108, 111, 99, 107, 78, 117, 109), + ::capnp::word(98, 101, 114, 0, 0, 0, 0, 0), + ::capnp::word(9, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(9, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(116, 105, 109, 101, 115, 116, 97, 109), + ::capnp::word(112, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(5, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(5, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(102, 105, 114, 115, 116, 66, 108, 111), + ::capnp::word(99, 107, 78, 117, 109, 98, 101, 114), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(9, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(9, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(102, 105, 114, 115, 116, 80, 97, 114), + ::capnp::word(101, 110, 116, 72, 97, 115, 104, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ]; + pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { + match index { + 0 => <::capnp::data::Owned as ::capnp::introspect::Introspect>::introspect(), + 1 => ::introspect(), + 2 => ::introspect(), + 3 => ::introspect(), + 4 => <::capnp::data::Owned as ::capnp::introspect::Introspect>::introspect(), + _ => panic!("invalid field index {}", index), + } + } + pub fn get_annotation_types( + child_index: Option, + index: u32, + ) -> ::capnp::introspect::Type { + panic!("invalid annotation indices ({:?}, {}) ", child_index, index) + } + pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = + ::capnp::introspect::RawStructSchema { + encoded_node: &ENCODED_NODE, + nonunion_members: NONUNION_MEMBERS, + members_by_discriminant: MEMBERS_BY_DISCRIMINANT, + members_by_name: MEMBERS_BY_NAME, + }; + pub static NONUNION_MEMBERS: &[u16] = &[0, 1, 2, 3, 4]; + pub static MEMBERS_BY_DISCRIMINANT: &[u16] = &[]; + pub static MEMBERS_BY_NAME: &[u16] = &[1, 3, 4, 0, 2]; + pub const TYPE_ID: u64 = 0x957d_56ef_57fd_af4b; + } +} + +pub mod query_response { + #[derive(Copy, Clone)] + pub struct Owned(()); + impl ::capnp::introspect::Introspect for Owned { + fn introspect() -> ::capnp::introspect::Type { + ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }) + .into() + } + } + impl ::capnp::traits::Owned for Owned { + type Reader<'a> = Reader<'a>; + type Builder<'a> = Builder<'a>; + } + impl ::capnp::traits::OwnedStruct for Owned { + type Reader<'a> = Reader<'a>; + type Builder<'a> = Builder<'a>; + } + impl ::capnp::traits::Pipelined for Owned { + type Pipeline = Pipeline; + } + + pub struct Reader<'a> { + reader: ::capnp::private::layout::StructReader<'a>, + } + impl ::core::marker::Copy for Reader<'_> {} + impl ::core::clone::Clone for Reader<'_> { + fn clone(&self) -> Self { + *self + } + } + + impl ::capnp::traits::HasTypeId for Reader<'_> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl<'a> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a> { + fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { + Self { reader } + } + } + + impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { + fn from(reader: Reader<'a>) -> Self { + Self::Struct(::capnp::dynamic_struct::Reader::new( + reader.reader, + ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }), + )) + } + } + + impl ::core::fmt::Debug for Reader<'_> { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::result::Result<(), ::core::fmt::Error> { + core::fmt::Debug::fmt( + &::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), + f, + ) + } + } + + impl<'a> ::capnp::traits::FromPointerReader<'a> for Reader<'a> { + fn get_from_pointer( + reader: &::capnp::private::layout::PointerReader<'a>, + default: ::core::option::Option<&'a [::capnp::Word]>, + ) -> ::capnp::Result { + ::core::result::Result::Ok(reader.get_struct(default)?.into()) + } + } + + impl<'a> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a> { + fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> { + self.reader + } + } + + impl<'a> ::capnp::traits::Imbue<'a> for Reader<'a> { + fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) { + self.reader + .imbue(::capnp::private::layout::CapTableReader::Plain(cap_table)) + } + } + + impl<'a> Reader<'a> { + pub fn reborrow(&self) -> Reader<'_> { + Self { ..*self } + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn get_archive_height(self) -> i64 { + self.reader.get_data_field::(0) + } + #[inline] + pub fn get_next_block(self) -> u64 { + self.reader.get_data_field::(1) + } + #[inline] + pub fn get_total_execution_time(self) -> u64 { + self.reader.get_data_field::(2) + } + #[inline] + pub fn get_data( + self, + ) -> ::capnp::Result> + { + ::capnp::traits::FromPointerReader::get_from_pointer( + &self.reader.get_pointer_field(0), + ::core::option::Option::None, + ) + } + #[inline] + pub fn has_data(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_rollback_guard( + self, + ) -> ::capnp::Result> { + ::capnp::traits::FromPointerReader::get_from_pointer( + &self.reader.get_pointer_field(1), + ::core::option::Option::None, + ) + } + #[inline] + pub fn has_rollback_guard(&self) -> bool { + !self.reader.get_pointer_field(1).is_null() + } + } + + pub struct Builder<'a> { + builder: ::capnp::private::layout::StructBuilder<'a>, + } + impl ::capnp::traits::HasStructSize for Builder<'_> { + const STRUCT_SIZE: ::capnp::private::layout::StructSize = + ::capnp::private::layout::StructSize { + data: 3, + pointers: 2, + }; + } + impl ::capnp::traits::HasTypeId for Builder<'_> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl<'a> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a> { + fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { + Self { builder } + } + } + + impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { + fn from(builder: Builder<'a>) -> Self { + Self::Struct(::capnp::dynamic_struct::Builder::new( + builder.builder, + ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { + generic: &_private::RAW_SCHEMA, + field_types: _private::get_field_types, + annotation_types: _private::get_annotation_types, + }), + )) + } + } + + impl<'a> ::capnp::traits::ImbueMut<'a> for Builder<'a> { + fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) { + self.builder + .imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table)) + } + } + + impl<'a> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a> { + fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self { + builder + .init_struct(::STRUCT_SIZE) + .into() + } + fn get_from_pointer( + builder: ::capnp::private::layout::PointerBuilder<'a>, + default: ::core::option::Option<&'a [::capnp::Word]>, + ) -> ::capnp::Result { + ::core::result::Result::Ok( + builder + .get_struct( + ::STRUCT_SIZE, + default, + )? + .into(), + ) + } + } + + impl ::capnp::traits::SetterInput for Reader<'_> { + fn set_pointer_builder( + mut pointer: ::capnp::private::layout::PointerBuilder<'_>, + value: Self, + canonicalize: bool, + ) -> ::capnp::Result<()> { + pointer.set_struct(&value.reader, canonicalize) + } + } + + impl<'a> Builder<'a> { + pub fn into_reader(self) -> Reader<'a> { + self.builder.into_reader().into() + } + pub fn reborrow(&mut self) -> Builder<'_> { + Builder { + builder: self.builder.reborrow(), + } + } + pub fn reborrow_as_reader(&self) -> Reader<'_> { + self.builder.as_reader().into() + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() + } + #[inline] + pub fn get_archive_height(self) -> i64 { + self.builder.get_data_field::(0) + } + #[inline] + pub fn set_archive_height(&mut self, value: i64) { + self.builder.set_data_field::(0, value); + } + #[inline] + pub fn get_next_block(self) -> u64 { + self.builder.get_data_field::(1) + } + #[inline] + pub fn set_next_block(&mut self, value: u64) { + self.builder.set_data_field::(1, value); + } + #[inline] + pub fn get_total_execution_time(self) -> u64 { + self.builder.get_data_field::(2) + } + #[inline] + pub fn set_total_execution_time(&mut self, value: u64) { + self.builder.set_data_field::(2, value); + } + #[inline] + pub fn get_data( + self, + ) -> ::capnp::Result> + { + ::capnp::traits::FromPointerBuilder::get_from_pointer( + self.builder.get_pointer_field(0), + ::core::option::Option::None, + ) + } + #[inline] + pub fn set_data( + &mut self, + value: crate::hypersync_net_types_capnp::query_response_data::Reader<'_>, + ) -> ::capnp::Result<()> { + ::capnp::traits::SetterInput::set_pointer_builder( + self.builder.reborrow().get_pointer_field(0), + value, + false, + ) + } + #[inline] + pub fn init_data( + self, + ) -> crate::hypersync_net_types_capnp::query_response_data::Builder<'a> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(0), 0) + } + #[inline] + pub fn has_data(&self) -> bool { + !self.builder.is_pointer_field_null(0) + } + #[inline] + pub fn get_rollback_guard( + self, + ) -> ::capnp::Result> + { + ::capnp::traits::FromPointerBuilder::get_from_pointer( + self.builder.get_pointer_field(1), + ::core::option::Option::None, + ) + } + #[inline] + pub fn set_rollback_guard( + &mut self, + value: crate::hypersync_net_types_capnp::rollback_guard::Reader<'_>, + ) -> ::capnp::Result<()> { + ::capnp::traits::SetterInput::set_pointer_builder( + self.builder.reborrow().get_pointer_field(1), + value, + false, + ) + } + #[inline] + pub fn init_rollback_guard( + self, + ) -> crate::hypersync_net_types_capnp::rollback_guard::Builder<'a> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0) + } + #[inline] + pub fn has_rollback_guard(&self) -> bool { + !self.builder.is_pointer_field_null(1) + } + } + + pub struct Pipeline { + _typeless: ::capnp::any_pointer::Pipeline, + } + impl ::capnp::capability::FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { + Self { + _typeless: typeless, + } + } + } + impl Pipeline { + pub fn get_data(&self) -> crate::hypersync_net_types_capnp::query_response_data::Pipeline { + ::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(0)) + } + pub fn get_rollback_guard( + &self, + ) -> crate::hypersync_net_types_capnp::rollback_guard::Pipeline { + ::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(1)) + } + } + mod _private { + pub static ENCODED_NODE: [::capnp::Word; 99] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(226, 9, 54, 243, 16, 76, 106, 205), + ::capnp::word(26, 0, 0, 0, 1, 0, 3, 0), + ::capnp::word(197, 128, 248, 24, 106, 165, 137, 146), + ::capnp::word(2, 0, 7, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 66, 1, 0, 0), + ::capnp::word(37, 0, 0, 0, 7, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(33, 0, 0, 0, 31, 1, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(104, 121, 112, 101, 114, 115, 121, 110), + ::capnp::word(99, 95, 110, 101, 116, 95, 116, 121), + ::capnp::word(112, 101, 115, 46, 99, 97, 112, 110), + ::capnp::word(112, 58, 81, 117, 101, 114, 121, 82), + ::capnp::word(101, 115, 112, 111, 110, 115, 101, 0), + ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(20, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(125, 0, 0, 0, 114, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(124, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(136, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(1, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(133, 0, 0, 0, 82, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(132, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(144, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(2, 0, 0, 0, 2, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 2, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(141, 0, 0, 0, 154, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(144, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(156, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(3, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 3, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(153, 0, 0, 0, 42, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(148, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(160, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(4, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 4, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(157, 0, 0, 0, 114, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(156, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(168, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(97, 114, 99, 104, 105, 118, 101, 72), + ::capnp::word(101, 105, 103, 104, 116, 0, 0, 0), + ::capnp::word(5, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(5, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(110, 101, 120, 116, 66, 108, 111, 99), + ::capnp::word(107, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(9, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(9, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(116, 111, 116, 97, 108, 69, 120, 101), + ::capnp::word(99, 117, 116, 105, 111, 110, 84, 105), + ::capnp::word(109, 101, 0, 0, 0, 0, 0, 0), + ::capnp::word(9, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(9, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(100, 97, 116, 97, 0, 0, 0, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(49, 157, 62, 151, 169, 39, 204, 137), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(114, 111, 108, 108, 98, 97, 99, 107), + ::capnp::word(71, 117, 97, 114, 100, 0, 0, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(75, 175, 253, 87, 239, 86, 125, 149), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ]; + pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { + match index { + 0 => ::introspect(), + 1 => ::introspect(), + 2 => ::introspect(), + 3 => ::introspect(), + 4 => ::introspect(), + _ => panic!("invalid field index {}", index), + } + } + pub fn get_annotation_types( + child_index: Option, + index: u32, + ) -> ::capnp::introspect::Type { + panic!("invalid annotation indices ({:?}, {}) ", child_index, index) + } + pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = + ::capnp::introspect::RawStructSchema { + encoded_node: &ENCODED_NODE, + nonunion_members: NONUNION_MEMBERS, + members_by_discriminant: MEMBERS_BY_DISCRIMINANT, + members_by_name: MEMBERS_BY_NAME, + }; + pub static NONUNION_MEMBERS: &[u16] = &[0, 1, 2, 3, 4]; + pub static MEMBERS_BY_DISCRIMINANT: &[u16] = &[]; + pub static MEMBERS_BY_NAME: &[u16] = &[0, 3, 1, 4, 2]; + pub const TYPE_ID: u64 = 0xcd6a_4c10_f336_09e2; + } +} diff --git a/hypersync-net-types/src/lib.rs b/hypersync-net-types/src/lib.rs index 9086696..ad15212 100644 --- a/hypersync-net-types/src/lib.rs +++ b/hypersync-net-types/src/lib.rs @@ -6,9 +6,7 @@ use serde::{Deserialize, Serialize}; pub type Sighash = FixedSizeData<4>; -pub mod hypersync_net_types_capnp { - include!(concat!(env!("OUT_DIR"), "/hypersync_net_types_capnp.rs")); -} +pub mod hypersync_net_types_capnp; #[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct BlockSelection {