chore: rename chainhook-postgres to postgres and fold chainhook-types-rs into bitcoind (#464)

* chainhook types

* rename postgres

* fmt
This commit is contained in:
Rafael Cárdenas
2025-03-14 07:28:28 -06:00
committed by GitHub
parent 9a4218facd
commit 74dca812df
71 changed files with 504 additions and 440 deletions

View File

@@ -127,7 +127,7 @@ jobs:
matrix:
suite:
- bitcoind
- chainhook-postgres
- postgres
- cli
- ordinals
- runes
@@ -221,7 +221,7 @@ jobs:
matrix:
suite:
- bitcoind
- chainhook-postgres
- postgres
- cli
- ordinals
- runes

547
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,7 @@
[workspace]
members = [
"components/bitcoind",
"components/chainhook-postgres",
"components/chainhook-types-rs",
"components/postgres",
"components/cli",
"components/config",
"components/ordinals",

View File

@@ -27,7 +27,8 @@ crossbeam-channel = "0.5.6"
hex = "0.4.3"
zmq = "0.10.0"
lazy_static = "1.4.0"
chainhook-types = { path = "../chainhook-types-rs" }
schemars = { version = "0.8.16", git = "https://github.com/hirosystems/schemars.git", branch = "feat-chainhook-fixes" }
strum = { version = "0.23.0", features = ["derive"] }
[dev-dependencies]
assert-json-diff = "2.0.2"

View File

@@ -1,8 +1,7 @@
use std::io::{Cursor, Read, Write};
use chainhook_types::BitcoinBlockData;
use super::BitcoinBlockFullBreakdown;
use crate::types::BitcoinBlockData;
#[derive(Debug)]
pub struct BlockBytesCursor<'a> {
@@ -366,11 +365,10 @@ impl Iterator for TransactionBytesCursorIterator<'_> {
#[cfg(test)]
mod tests {
use chainhook_types::BitcoinNetwork;
use super::*;
use crate::{
indexer::bitcoin::{parse_downloaded_block, standardize_bitcoin_block},
types::BitcoinNetwork,
utils::Context,
};

View File

@@ -8,17 +8,20 @@ use bitcoincore_rpc::{
jsonrpc::error::RpcError,
};
use bitcoincore_rpc_json::GetRawTransactionResultVoutScriptPubKey;
use chainhook_types::{
bitcoin::{OutPoint, TxIn, TxOut},
BitcoinBlockData, BitcoinBlockMetadata, BitcoinNetwork, BitcoinTransactionData,
BitcoinTransactionMetadata, BlockHeader, BlockIdentifier, TransactionIdentifier,
};
use config::BitcoindConfig;
use hiro_system_kit::slog;
use reqwest::Client as HttpClient;
use serde::Deserialize;
use crate::{try_debug, utils::Context};
use crate::{
try_debug,
types::{
bitcoin::{OutPoint, TxIn, TxOut},
BitcoinBlockData, BitcoinBlockMetadata, BitcoinNetwork, BitcoinTransactionData,
BitcoinTransactionMetadata, BlockHeader, BlockIdentifier, TransactionIdentifier,
},
utils::Context,
};
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]

View File

@@ -4,7 +4,6 @@ use std::{
time::Duration,
};
use chainhook_types::BitcoinNetwork;
use config::Config;
use crossbeam_channel::bounded;
use reqwest::Client;
@@ -19,6 +18,7 @@ use crate::{
BlockProcessor, BlockProcessorCommand, BlockProcessorEvent,
},
try_debug, try_info,
types::BitcoinNetwork,
utils::Context,
};

View File

@@ -1,9 +1,8 @@
use std::collections::VecDeque;
use chainhook_types::BlockIdentifier;
use crate::{
try_debug, try_info, try_warn,
types::BlockIdentifier,
utils::{AbstractBlock, Context},
};

View File

@@ -1,13 +1,16 @@
use std::collections::{BTreeMap, BTreeSet, HashSet};
use chainhook_types::{
BlockHeader, BlockIdentifier, BlockchainEvent, BlockchainUpdatedWithHeaders,
BlockchainUpdatedWithReorg,
};
use hiro_system_kit::slog;
use super::chain_segment::{ChainSegment, ChainSegmentIncompatibility};
use crate::{try_debug, try_error, try_info, try_warn, utils::Context};
use crate::{
try_debug, try_error, try_info, try_warn,
types::{
BlockHeader, BlockIdentifier, BlockchainEvent, BlockchainUpdatedWithHeaders,
BlockchainUpdatedWithReorg,
},
utils::Context,
};
pub struct ForkScratchPad {
canonical_fork_id: usize,

View File

@@ -13,7 +13,6 @@ use bitcoin::{
build_http_client, download_and_parse_block_with_retry,
pipeline::start_block_download_pipeline, standardize_bitcoin_block,
};
use chainhook_types::{BitcoinBlockData, BitcoinNetwork, BlockIdentifier, BlockchainEvent};
use config::Config;
use crossbeam_channel::{Receiver, Sender, TryRecvError};
use reqwest::Client;
@@ -22,6 +21,7 @@ use self::fork_scratch_pad::ForkScratchPad;
use crate::{
observer::zmq::start_zeromq_pipeline,
try_debug, try_info,
types::{BitcoinBlockData, BitcoinNetwork, BlockIdentifier, BlockchainEvent},
utils::{
bitcoind::{bitcoind_get_chain_tip, bitcoind_wait_for_chain_tip},
future_block_on, AbstractBlock, BlockHeights, Context,

View File

@@ -1,4 +1,4 @@
use chainhook_types::{
use crate::types::{
BitcoinBlockData, BitcoinBlockMetadata, BitcoinTransactionData, BlockIdentifier,
};
@@ -50,7 +50,7 @@ pub fn generate_test_bitcoin_block(
timestamp: 0,
transactions,
metadata: BitcoinBlockMetadata {
network: chainhook_types::BitcoinNetwork::Regtest,
network: crate::types::BitcoinNetwork::Regtest,
},
}
}

View File

@@ -1,8 +1,10 @@
use chainhook_types::{BitcoinBlockData, BlockchainEvent};
use hiro_system_kit::slog;
use super::{super::BlockchainEventExpectation, bitcoin_blocks};
use crate::utils::Context;
use crate::{
types::{BitcoinBlockData, BlockchainEvent},
utils::Context,
};
pub fn expect_no_chain_update() -> BlockchainEventExpectation {
Box::new(move |chain_event_to_check: Option<BlockchainEvent>| {

View File

@@ -1,6 +1,7 @@
use base58::FromBase58;
use bitcoincore_rpc::bitcoin::blockdata::{opcodes, script::Builder as BitcoinScriptBuilder};
use chainhook_types::{
use crate::types::{
bitcoin::TxOut, BitcoinTransactionData, BitcoinTransactionMetadata, TransactionIdentifier,
};

View File

@@ -1,8 +1,9 @@
pub mod helpers;
use chainhook_types::{BitcoinBlockData, BlockchainEvent};
use super::fork_scratch_pad::ForkScratchPad;
use crate::utils::{AbstractBlock, Context};
use crate::{
types::{BitcoinBlockData, BlockchainEvent},
utils::{AbstractBlock, Context},
};
pub type BlockchainEventExpectation = Box<dyn Fn(Option<BlockchainEvent>)>;

View File

@@ -10,4 +10,5 @@ pub use bitcoincore_rpc;
pub mod indexer;
pub mod observer;
pub mod types;
pub mod utils;

View File

@@ -1,4 +1,3 @@
use chainhook_types::BitcoinNetwork;
use config::Config;
use zmq::Socket;
@@ -11,6 +10,7 @@ use crate::{
BlockProcessor, BlockProcessorCommand,
},
try_info, try_warn,
types::BitcoinNetwork,
utils::Context,
};

View File

@@ -1,4 +1,4 @@
use crate::TransactionIdentifier;
use super::TransactionIdentifier;
/// A transaction input, which defines old coins to be consumed
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Serialize, Deserialize)]

View File

@@ -1,8 +1,3 @@
extern crate serde;
#[macro_use]
extern crate serde_derive;
pub mod bitcoin;
mod ordinals;
mod processors;

View File

@@ -7,10 +7,9 @@ use std::{
use bitcoin::Network;
use schemars::JsonSchema;
use crate::{
use super::{
bitcoin::{TxIn, TxOut},
ordinals::OrdinalOperation,
Brc20Operation,
Brc20Operation, OrdinalOperation,
};
/// BlockIdentifier uniquely identifies a block in a particular network.

View File

@@ -1,10 +1,9 @@
use std::{thread::sleep, time::Duration};
use bitcoincore_rpc::{Auth, Client, RpcApi};
use chainhook_types::BlockIdentifier;
use config::BitcoindConfig;
use crate::{try_error, try_info, utils::Context};
use crate::{try_error, try_info, types::BlockIdentifier, utils::Context};
fn bitcoind_get_client(config: &BitcoindConfig, ctx: &Context) -> Client {
loop {

View File

@@ -7,11 +7,13 @@ use std::{
path::Path,
};
use chainhook_types::{BitcoinBlockData, BlockHeader, BlockIdentifier};
use hiro_system_kit::{slog, Logger};
use reqwest::RequestBuilder;
use crate::try_crit;
use crate::{
try_crit,
types::{BitcoinBlockData, BlockHeader, BlockIdentifier},
};
#[derive(Clone)]
pub struct Context {

View File

@@ -1,17 +0,0 @@
[package]
name = "chainhook-types"
description = "Bitcoin and Stacks data schemas, based on the Rosetta specification"
license = "MIT"
version = "1.3.8"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bitcoin = { workspace = true }
serde = "1"
serde_json = "1"
serde_derive = "1"
strum = { version = "0.23.0", features = ["derive"] }
schemars = { version = "0.8.16", git = "https://github.com/hirosystems/schemars.git", branch = "feat-chainhook-fixes" }
hex = "0.4.3"

View File

@@ -15,7 +15,6 @@ path = "src/lib.rs"
config = { path = "../config" }
ordinals = { path = "../ordinals" }
runes = { path = "../runes" }
chainhook-types = { path = "../chainhook-types-rs" }
bitcoind = { path = "../bitcoind" }
hex = "0.4.3"
num_cpus = "1.16.0"

View File

@@ -1,7 +1,6 @@
use std::{path::PathBuf, process, thread::sleep, time::Duration};
use bitcoind::{try_error, try_info, utils::Context};
use chainhook_types::BlockIdentifier;
use bitcoind::{try_error, try_info, types::BlockIdentifier, utils::Context};
use clap::Parser;
use commands::{Command, ConfigCommand, DatabaseCommand, IndexCommand, Protocol, ServiceCommand};
use config::{generator::generate_toml_config, Config};

View File

@@ -14,7 +14,6 @@ lru = "0.13.0"
config = { path = "../config" }
bitcoin = { workspace = true }
bitcoind = { path = "../bitcoind" }
chainhook-types = { path = "../chainhook-types-rs" }
hiro-system-kit = { workspace = true }
reqwest = { version = "0.11", default-features = false, features = [
"stream",
@@ -43,7 +42,7 @@ hyper = { version = "=0.14.27" }
lazy_static = { version = "1.4.0" }
regex = "1.10.3"
prometheus = "0.13.3"
chainhook-postgres = { path = "../chainhook-postgres" }
postgres = { path = "../postgres" }
tokio-postgres = { workspace = true }
deadpool-postgres = { workspace = true }
refinery = { workspace = true }

View File

@@ -1,10 +1,10 @@
use std::collections::HashMap;
use chainhook_postgres::{
use deadpool_postgres::GenericClient;
use postgres::{
types::{PgNumericU128, PgNumericU64},
utils, FromPgRow, BATCH_QUERY_CHUNK_SIZE,
};
use deadpool_postgres::GenericClient;
use refinery::embed_migrations;
use tokio_postgres::{types::ToSql, Client};
@@ -497,15 +497,15 @@ pub async fn rollback_block_operations<T: GenericClient>(
mod test {
use std::collections::HashMap;
use chainhook_postgres::{
use bitcoind::types::{
BlockIdentifier, OrdinalInscriptionTransferDestination, TransactionIdentifier,
};
use deadpool_postgres::GenericClient;
use postgres::{
pg_begin, pg_pool_client,
types::{PgBigIntU32, PgNumericU128, PgNumericU64, PgSmallIntU8},
FromPgRow,
};
use chainhook_types::{
BlockIdentifier, OrdinalInscriptionTransferDestination, TransactionIdentifier,
};
use deadpool_postgres::GenericClient;
use crate::{
core::meta_protocols::brc20::{

View File

@@ -3,8 +3,7 @@ use std::{
num::NonZeroUsize,
};
use chainhook_postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64, PgSmallIntU8};
use chainhook_types::{
use bitcoind::types::{
BlockIdentifier, OrdinalInscriptionRevealData, OrdinalInscriptionTransferData,
TransactionIdentifier,
};
@@ -12,6 +11,7 @@ use config::Config;
use deadpool_postgres::GenericClient;
use lru::LruCache;
use maplit::hashmap;
use postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64, PgSmallIntU8};
use super::{
brc20_pg,
@@ -486,8 +486,8 @@ impl Brc20MemoryCache {
#[cfg(test)]
mod test {
use chainhook_postgres::{pg_begin, pg_pool_client};
use chainhook_types::{BitcoinNetwork, BlockIdentifier, TransactionIdentifier};
use bitcoind::types::{BitcoinNetwork, BlockIdentifier, TransactionIdentifier};
use postgres::{pg_begin, pg_pool_client};
use test_case::test_case;
use super::Brc20MemoryCache;

View File

@@ -1,9 +1,12 @@
use std::collections::HashMap;
use bitcoind::{try_info, utils::Context};
use chainhook_types::{
use bitcoind::{
try_info,
types::{
BitcoinBlockData, BlockIdentifier, Brc20BalanceData, Brc20Operation, Brc20TokenDeployData,
Brc20TransferData, OrdinalInscriptionTransferData, OrdinalOperation, TransactionIdentifier,
},
utils::Context,
};
use deadpool_postgres::Transaction;
@@ -262,11 +265,11 @@ pub async fn index_block_and_insert_brc20_operations(
mod test {
use std::collections::HashMap;
use chainhook_postgres::{pg_begin, pg_pool_client};
use chainhook_types::{
use bitcoind::types::{
Brc20BalanceData, Brc20Operation, Brc20TokenDeployData, Brc20TransferData,
OrdinalInscriptionTransferDestination, OrdinalOperation,
};
use postgres::{pg_begin, pg_pool_client};
use crate::{
core::{

View File

@@ -1,4 +1,4 @@
use chainhook_types::BitcoinNetwork;
use bitcoind::types::BitcoinNetwork;
pub mod brc20_pg;
pub mod cache;

View File

@@ -1,4 +1,4 @@
use chainhook_postgres::{
use postgres::{
types::{PgBigIntU32, PgNumericU128, PgNumericU64},
FromPgRow,
};

View File

@@ -1,4 +1,4 @@
use chainhook_postgres::{
use postgres::{
types::{PgBigIntU32, PgNumericU128, PgNumericU64, PgSmallIntU8},
FromPgRow,
};

View File

@@ -1,7 +1,9 @@
use bitcoind::utils::Context;
use chainhook_types::{
use bitcoind::{
types::{
OrdinalInscriptionNumber, OrdinalInscriptionRevealData, OrdinalInscriptionTransferData,
OrdinalInscriptionTransferDestination,
},
utils::Context,
};
pub fn get_test_ctx() -> Context {

View File

@@ -1,9 +1,12 @@
use std::collections::HashMap;
use bitcoind::utils::Context;
use chainhook_types::{
BitcoinNetwork, BlockIdentifier, OrdinalInscriptionRevealData, OrdinalInscriptionTransferData,
OrdinalInscriptionTransferDestination, TransactionIdentifier,
use bitcoind::{
types::{
BitcoinNetwork, BlockIdentifier, OrdinalInscriptionRevealData,
OrdinalInscriptionTransferData, OrdinalInscriptionTransferDestination,
TransactionIdentifier,
},
utils::Context,
};
use deadpool_postgres::Transaction;
@@ -298,12 +301,12 @@ pub async fn verify_brc20_transfers(
#[cfg(test)]
mod test {
use chainhook_postgres::{pg_begin, pg_pool_client};
use chainhook_types::{
use bitcoind::types::{
BitcoinNetwork, BlockIdentifier, OrdinalInscriptionRevealData,
OrdinalInscriptionTransferData, OrdinalInscriptionTransferDestination,
TransactionIdentifier,
};
use postgres::{pg_begin, pg_pool_client};
use test_case::test_case;
use super::{verify_brc20_operation, verify_brc20_transfers, VerifiedBrc20TransferData};

View File

@@ -5,13 +5,15 @@ use std::{
};
use bitcoind::{
indexer::bitcoin::cursor::TransactionBytesCursor, try_info, try_warn, utils::Context,
indexer::bitcoin::cursor::TransactionBytesCursor,
try_info, try_warn,
types::{BitcoinBlockData, TransactionIdentifier},
utils::Context,
};
use chainhook_postgres::{pg_begin, pg_pool_client};
use chainhook_types::{BitcoinBlockData, TransactionIdentifier};
use config::Config;
use dashmap::DashMap;
use fxhash::FxHasher;
use postgres::{pg_begin, pg_pool_client};
use crate::{
core::{

View File

@@ -1,11 +1,14 @@
use std::{collections::HashMap, str, str::FromStr};
use bitcoin::{hash_types::Txid, Witness};
use bitcoind::{try_warn, utils::Context};
use chainhook_types::{
use bitcoind::{
try_warn,
types::{
BitcoinBlockData, BitcoinNetwork, BitcoinTransactionData, BlockIdentifier,
OrdinalInscriptionCurseType, OrdinalInscriptionNumber, OrdinalInscriptionRevealData,
OrdinalOperation,
},
utils::Context,
};
use config::Config;
use ord::{
@@ -169,8 +172,7 @@ pub fn parse_inscriptions_in_standardized_block(
mod test {
use std::collections::HashMap;
use bitcoind::utils::Context;
use chainhook_types::OrdinalOperation;
use bitcoind::{types::OrdinalOperation, utils::Context};
use config::Config;
use super::parse_inscriptions_in_standardized_block;

View File

@@ -6,13 +6,14 @@ use std::{
use bitcoin::Network;
use bitcoind::{
indexer::bitcoin::cursor::TransactionBytesCursor, try_debug, try_error, try_info,
utils::Context,
};
use chainhook_types::{
indexer::bitcoin::cursor::TransactionBytesCursor,
try_debug, try_error, try_info,
types::{
BitcoinBlockData, BitcoinNetwork, BitcoinTransactionData, BlockIdentifier,
OrdinalInscriptionCurseType, OrdinalInscriptionTransferDestination, OrdinalOperation,
TransactionIdentifier,
},
utils::Context,
};
use config::Config;
use crossbeam_channel::unbounded;
@@ -602,14 +603,16 @@ async fn update_tx_inscriptions_with_consensus_sequence_data(
mod test {
use std::collections::BTreeMap;
use bitcoind::utils::Context;
use chainhook_postgres::{pg_begin, pg_pool_client};
use chainhook_types::{
use bitcoind::{
types::{
bitcoin::{OutPoint, TxIn, TxOut},
OrdinalInscriptionCurseType, OrdinalInscriptionNumber, OrdinalInscriptionRevealData,
OrdinalOperation, TransactionIdentifier,
},
utils::Context,
};
use ord::charm::Charm;
use postgres::{pg_begin, pg_pool_client};
use test_case::test_case;
use super::update_block_inscriptions_with_consensus_sequence_data;

View File

@@ -3,9 +3,9 @@ use std::{hash::BuildHasherDefault, sync::Arc};
use bitcoind::{
indexer::bitcoin::cursor::{BlockBytesCursor, TransactionBytesCursor},
try_error,
types::{BlockIdentifier, OrdinalInscriptionNumber, TransactionIdentifier},
utils::Context,
};
use chainhook_types::{BlockIdentifier, OrdinalInscriptionNumber, TransactionIdentifier};
use config::Config;
use dashmap::DashMap;
use fxhash::FxHasher;
@@ -305,9 +305,9 @@ mod test {
use bitcoind::{
indexer::bitcoin::cursor::{TransactionBytesCursor, TransactionInputBytesCursor},
types::{bitcoin::TxOut, BlockIdentifier, TransactionIdentifier},
utils::Context,
};
use chainhook_types::{bitcoin::TxOut, BlockIdentifier, TransactionIdentifier};
use config::Config;
use dashmap::DashMap;
use fxhash::FxHasher;

View File

@@ -1,10 +1,13 @@
use std::collections::{HashMap, HashSet};
use bitcoin::{Address, Network, ScriptBuf};
use bitcoind::{try_info, utils::Context};
use chainhook_types::{
use bitcoind::{
try_info,
types::{
BitcoinBlockData, BitcoinTransactionData, BlockIdentifier, OrdinalInscriptionTransferData,
OrdinalInscriptionTransferDestination, OrdinalOperation,
},
utils::Context,
};
use deadpool_postgres::Transaction;
@@ -250,12 +253,14 @@ pub async fn augment_transaction_with_ordinal_transfers(
#[cfg(test)]
mod test {
use bitcoin::Network;
use bitcoind::utils::Context;
use chainhook_postgres::{pg_begin, pg_pool_client};
use chainhook_types::{
use bitcoind::{
types::{
OrdinalInscriptionNumber, OrdinalInscriptionRevealData, OrdinalInscriptionTransferData,
OrdinalInscriptionTransferDestination, OrdinalOperation,
},
utils::Context,
};
use postgres::{pg_begin, pg_pool_client};
use super::compute_satpoint_post_transfer;
use crate::{

View File

@@ -1,5 +1,5 @@
use bitcoin::Network;
use chainhook_types::OrdinalInscriptionNumber;
use bitcoind::types::OrdinalInscriptionNumber;
use deadpool_postgres::GenericClient;
use super::inscription_sequencing;
@@ -170,8 +170,8 @@ impl SequenceCursor {
#[cfg(test)]
mod test {
use bitcoin::Network;
use chainhook_postgres::{pg_begin, pg_pool_client};
use chainhook_types::OrdinalOperation;
use bitcoind::types::OrdinalOperation;
use postgres::{pg_begin, pg_pool_client};
use test_case::test_case;
use super::SequenceCursor;

View File

@@ -1,4 +1,4 @@
use chainhook_types::{
use bitcoind::types::{
bitcoin::{OutPoint, TxIn, TxOut},
BitcoinBlockData, BitcoinBlockMetadata, BitcoinNetwork, BitcoinTransactionData,
BitcoinTransactionMetadata, BlockIdentifier, Brc20Operation, OrdinalInscriptionNumber,

View File

@@ -185,7 +185,7 @@ pub fn delete_blocks_in_block_range(
#[cfg(test)]
pub fn insert_standardized_block(
block: &chainhook_types::BitcoinBlockData,
block: &bitcoind::types::BitcoinBlockData,
blocks_db_rw: &DB,
ctx: &Context,
) {

View File

@@ -3,8 +3,8 @@ pub mod models;
pub mod ordinals_pg;
use bitcoind::{try_info, try_warn, utils::Context};
use chainhook_postgres::pg_connect_with_retry;
use config::Config;
use postgres::pg_connect_with_retry;
use crate::core::meta_protocols::brc20::brc20_pg;
@@ -81,14 +81,12 @@ pub fn pg_test_config() -> config::PgDatabaseConfig {
#[cfg(test)]
pub fn pg_test_connection_pool() -> deadpool_postgres::Pool {
chainhook_postgres::pg_pool(&pg_test_config()).unwrap()
postgres::pg_pool(&pg_test_config()).unwrap()
}
#[cfg(test)]
pub async fn pg_test_connection() -> tokio_postgres::Client {
chainhook_postgres::pg_connect(&pg_test_config())
.await
.unwrap()
postgres::pg_connect(&pg_test_config()).await.unwrap()
}
#[cfg(test)]

View File

@@ -1,11 +1,11 @@
use chainhook_postgres::{
types::{PgBigIntU32, PgNumericU64},
FromPgRow,
};
use chainhook_types::{
use bitcoind::types::{
BlockIdentifier, OrdinalInscriptionRevealData, OrdinalInscriptionTransferData,
OrdinalInscriptionTransferDestination, TransactionIdentifier,
};
use postgres::{
types::{PgBigIntU32, PgNumericU64},
FromPgRow,
};
use tokio_postgres::Row;
use crate::core::protocol::satoshi_tracking::parse_output_and_offset_from_satpoint;

View File

@@ -1,11 +1,11 @@
use chainhook_postgres::{
types::{PgBigIntU32, PgNumericU64},
FromPgRow,
};
use chainhook_types::{
use bitcoind::types::{
BlockIdentifier, OrdinalInscriptionCurseType, OrdinalInscriptionRevealData,
TransactionIdentifier,
};
use postgres::{
types::{PgBigIntU32, PgNumericU64},
FromPgRow,
};
use tokio_postgres::Row;
#[derive(Debug, Clone, PartialEq, Eq)]

View File

@@ -1,4 +1,4 @@
use chainhook_types::OrdinalInscriptionRevealData;
use bitcoind::types::OrdinalInscriptionRevealData;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DbInscriptionParent {

View File

@@ -1,4 +1,4 @@
use chainhook_types::OrdinalInscriptionRevealData;
use bitcoind::types::OrdinalInscriptionRevealData;
use regex::Regex;
lazy_static! {
@@ -33,7 +33,7 @@ impl DbInscriptionRecursion {
#[cfg(test)]
mod test {
use chainhook_types::{OrdinalInscriptionNumber, OrdinalInscriptionRevealData};
use bitcoind::types::{OrdinalInscriptionNumber, OrdinalInscriptionRevealData};
use super::DbInscriptionRecursion;

View File

@@ -1,11 +1,11 @@
use chainhook_postgres::{
types::{PgBigIntU32, PgNumericU64},
FromPgRow,
};
use chainhook_types::{
use bitcoind::types::{
BlockIdentifier, OrdinalInscriptionRevealData, OrdinalInscriptionTransferData,
OrdinalInscriptionTransferDestination, TransactionIdentifier,
};
use postgres::{
types::{PgBigIntU32, PgNumericU64},
FromPgRow,
};
use tokio_postgres::Row;
use crate::core::protocol::satoshi_tracking::parse_output_and_offset_from_satpoint;

View File

@@ -1,6 +1,6 @@
use chainhook_postgres::{types::PgNumericU64, FromPgRow};
use chainhook_types::OrdinalInscriptionRevealData;
use bitcoind::types::OrdinalInscriptionRevealData;
use ord::{rarity::Rarity, sat::Sat};
use postgres::{types::PgNumericU64, FromPgRow};
use tokio_postgres::Row;
#[derive(Debug, Clone, PartialEq, Eq)]

View File

@@ -1,14 +1,14 @@
use std::collections::{BTreeMap, HashMap};
use chainhook_postgres::{
types::{PgBigIntU32, PgNumericU64},
utils,
};
use chainhook_types::{
use bitcoind::types::{
BitcoinBlockData, BlockIdentifier, OrdinalInscriptionNumber, OrdinalOperation,
TransactionIdentifier,
};
use deadpool_postgres::GenericClient;
use postgres::{
types::{PgBigIntU32, PgNumericU64},
utils,
};
use refinery::embed_migrations;
use tokio_postgres::{types::ToSql, Client};
@@ -1053,16 +1053,16 @@ pub async fn rollback_block<T: GenericClient>(block_height: u64, client: &T) ->
#[cfg(test)]
mod test {
use chainhook_postgres::{
pg_begin, pg_pool_client,
types::{PgBigIntU32, PgNumericU64},
FromPgRow,
};
use chainhook_types::{
use bitcoind::types::{
OrdinalInscriptionNumber, OrdinalInscriptionRevealData, OrdinalInscriptionTransferData,
OrdinalInscriptionTransferDestination, OrdinalOperation,
};
use deadpool_postgres::GenericClient;
use postgres::{
pg_begin, pg_pool_client,
types::{PgBigIntU32, PgNumericU64},
FromPgRow,
};
use crate::{
core::test_builders::{TestBlockBuilder, TestTransactionBuilder},

View File

@@ -13,16 +13,16 @@ use std::{sync::Arc, thread::JoinHandle};
use bitcoind::{
indexer::{start_bitcoin_indexer, Indexer, IndexerCommand},
try_debug,
types::BlockIdentifier,
utils::{future_block_on, Context},
};
use chainhook_postgres::{pg_pool, pg_pool_client};
use chainhook_types::BlockIdentifier;
use config::Config;
use db::{
blocks::{self, find_last_block_inserted, open_blocks_db_with_retry},
migrate_dbs,
};
use deadpool_postgres::Pool;
use postgres::{pg_pool, pg_pool_client};
use utils::monitoring::PrometheusMonitoring;
#[macro_use]

View File

@@ -1,6 +1,6 @@
pub mod monitoring;
use chainhook_types::TransactionIdentifier;
use bitcoind::types::TransactionIdentifier;
pub fn format_inscription_id(
transaction_identifier: &TransactionIdentifier,

View File

@@ -1,5 +1,5 @@
[package]
name = "chainhook-postgres"
name = "postgres"
version.workspace = true
edition = "2021"

View File

@@ -5,7 +5,6 @@ edition = "2021"
[dependencies]
bitcoind = { path = "../bitcoind" }
chainhook-types = { path = "../chainhook-types-rs" }
bitcoin = { workspace = true }
lru = "0.12.3"
ordinals = "0.0.15"
@@ -17,11 +16,10 @@ hex = "0.4.3"
rand = "0.8.5"
hiro-system-kit = { workspace = true }
ctrlc = { version = "3.2.2", optional = true }
# reqwest = { version = "0.11", features = ["stream", "json"] }
crossbeam-channel = "0.5.8"
clap = { version = "4.3.2", features = ["derive"] }
clap_generate = { version = "3.0.3" }
chainhook-postgres = { path = "../chainhook-postgres" }
postgres = { path = "../postgres" }
tokio = { workspace = true }
tokio-postgres = { workspace = true }
deadpool-postgres = { workspace = true }

View File

@@ -1,8 +1,7 @@
use std::{collections::HashMap, num::NonZeroUsize, str::FromStr};
use bitcoin::{Network, ScriptBuf};
use bitcoind::{try_debug, try_info, try_warn, utils::Context};
use chainhook_types::bitcoin::TxIn;
use bitcoind::{try_debug, try_info, try_warn, types::bitcoin::TxIn, utils::Context};
use config::Config;
use lru::LruCache;
use ordinals::{Cenotaph, Edict, Etching, Rune, RuneId, Runestone};

View File

@@ -1,8 +1,7 @@
use std::collections::{HashMap, VecDeque};
use bitcoin::{Address, ScriptBuf};
use bitcoind::{try_info, try_warn, utils::Context};
use chainhook_types::bitcoin::TxIn;
use bitcoind::{try_info, try_warn, types::bitcoin::TxIn, utils::Context};
use lru::LruCache;
use ordinals::RuneId;
use tokio_postgres::Transaction;
@@ -584,7 +583,7 @@ mod test {
}
mod mint_validation {
use chainhook_postgres::types::{PgNumericU128, PgNumericU64};
use postgres::types::{PgNumericU128, PgNumericU64};
use test_case::test_case;
use crate::db::{
@@ -683,10 +682,12 @@ mod test {
mod input_balances {
use std::num::NonZeroUsize;
use bitcoind::utils::Context;
use chainhook_types::{
use bitcoind::{
types::{
bitcoin::{OutPoint, TxIn},
TransactionIdentifier,
},
utils::Context,
};
use lru::LruCache;
use maplit::hashmap;

View File

@@ -5,8 +5,11 @@ use bitcoin::{
transaction::{TxOut, Version},
Amount, Network, ScriptBuf, Transaction,
};
use bitcoind::{try_info, utils::Context};
use chainhook_types::{BitcoinBlockData, BitcoinTransactionData};
use bitcoind::{
try_info,
types::{BitcoinBlockData, BitcoinTransactionData},
utils::Context,
};
use ordinals::{Artifact, Runestone};
use tokio_postgres::Client;

View File

@@ -1,15 +1,14 @@
use std::{collections::HashMap, process, str::FromStr};
use bitcoind::{try_error, try_info, utils::Context};
use bitcoind::{try_error, try_info, types::BlockIdentifier, utils::Context};
use cache::input_rune_balance::InputRuneBalance;
use chainhook_postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64};
use chainhook_types::BlockIdentifier;
use config::Config;
use models::{
db_balance_change::DbBalanceChange, db_ledger_entry::DbLedgerEntry, db_rune::DbRune,
db_supply_change::DbSupplyChange,
};
use ordinals::RuneId;
use postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64};
use refinery::embed_migrations;
use tokio_postgres::{types::ToSql, Client, Error, GenericClient, NoTls, Transaction};

View File

@@ -1,4 +1,4 @@
use chainhook_postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64};
use postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64};
#[derive(Debug, Clone)]
pub struct DbBalanceChange {

View File

@@ -1,5 +1,5 @@
use chainhook_postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64};
use ordinals::RuneId;
use postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64};
use tokio_postgres::Row;
use super::db_ledger_operation::DbLedgerOperation;

View File

@@ -1,5 +1,5 @@
use chainhook_postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64, PgSmallIntU8};
use ordinals::{Etching, Rune, RuneId, SpacedRune};
use postgres::types::{PgBigIntU32, PgNumericU128, PgNumericU64, PgSmallIntU8};
use tokio_postgres::Row;
use crate::db::cache::transaction_location::TransactionLocation;

View File

@@ -1,4 +1,4 @@
use chainhook_postgres::types::{PgNumericU128, PgNumericU64};
use postgres::types::{PgNumericU128, PgNumericU64};
/// An update to a rune that affects its total counts.
#[derive(Debug, Clone)]

View File

@@ -2,9 +2,9 @@ use std::thread::JoinHandle;
use bitcoind::{
indexer::{start_bitcoin_indexer, Indexer, IndexerCommand},
types::BlockIdentifier,
utils::{future_block_on, Context},
};
use chainhook_types::BlockIdentifier;
use config::Config;
use db::{
cache::index_cache::IndexCache,