fix(build): add elasticsearch feature to block serialize (#6709)

* add elasticsearch feature to block serialize

* fix for elastic feature

* add zebra-chain elasticsearch dep to zebrad
This commit is contained in:
Alfredo Garcia 2023-06-14 16:01:39 -03:00 committed by GitHub
parent fe859bd6a1
commit 17bd7884ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 7 deletions

View File

@ -29,6 +29,9 @@ getblocktemplate-rpcs = [
"zcash_address",
]
# Experimental elasticsearch support
elasticsearch = []
# Test-only features
proptest-impl = [

View File

@ -43,7 +43,10 @@ pub use arbitrary::LedgerState;
/// A Zcash block, containing a header and a list of transactions.
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Serialize))]
#[cfg_attr(
any(test, feature = "proptest-impl", feature = "elasticsearch"),
derive(Serialize)
)]
pub struct Block {
/// The block header, containing block metadata.
pub header: Arc<Header>,

View File

@ -63,7 +63,10 @@ use crate::{
/// internally by different enum variants. Because we checkpoint on Canopy
/// activation, we do not validate any pre-Sapling transaction types.
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Serialize))]
#[cfg_attr(
any(test, feature = "proptest-impl", feature = "elasticsearch"),
derive(Serialize)
)]
pub enum Transaction {
/// A fully transparent transaction (`version = 1`).
V1 {

View File

@ -66,7 +66,10 @@ pub const EXTRA_ZEBRA_COINBASE_DATA: &str = "z\u{1F993}";
//
// TODO: rename to ExtraCoinbaseData, because height is also part of the coinbase data?
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Serialize))]
#[cfg_attr(
any(test, feature = "proptest-impl", feature = "elasticsearch"),
derive(Serialize)
)]
pub struct CoinbaseData(
/// Invariant: this vec, together with the coinbase height, must be less than
/// 100 bytes. We enforce this by only constructing CoinbaseData fields by
@ -110,7 +113,11 @@ impl std::fmt::Debug for CoinbaseData {
///
/// A particular transaction output reference.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary, Serialize))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl", feature = "elasticsearch"),
derive(Serialize)
)]
pub struct OutPoint {
/// References the transaction that contains the UTXO being spent.
///
@ -145,7 +152,10 @@ impl OutPoint {
/// A transparent input to a transaction.
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Serialize))]
#[cfg_attr(
any(test, feature = "proptest-impl", feature = "elasticsearch"),
derive(Serialize)
)]
pub enum Input {
/// A reference to an output of a previous transaction.
PrevOut {
@ -383,9 +393,10 @@ impl Input {
/// that spends my UTXO and sends 1 ZEC to you and 1 ZEC back to me
/// (just like receiving change).
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary, Deserialize))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(Arbitrary, Serialize, Deserialize)
any(test, feature = "proptest-impl", feature = "elasticsearch"),
derive(Serialize)
)]
pub struct Output {
/// Transaction value.

View File

@ -39,6 +39,7 @@ proptest-impl = [
elasticsearch = [
"dep:elasticsearch",
"dep:serde_json",
"zebra-chain/elasticsearch",
]
[dependencies]

View File

@ -44,6 +44,7 @@ getblocktemplate-rpcs = [
elasticsearch = [
"zebra-state/elasticsearch",
"zebra-chain/elasticsearch",
]
sentry = ["dep:sentry"]