1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use ckb_types::{
bytes::Bytes,
core::{HeaderView, TransactionView},
packed::{Byte32, CellOutput, OutPoint, Transaction},
};
use crate::traits::{
CellCollector, CellCollectorError, CellQueryOptions, HeaderDepResolver, LiveCell,
TransactionDependencyError, TransactionDependencyProvider,
};
use anyhow::anyhow;
#[derive(Default)]
pub struct DummyCellCollector;
impl CellCollector for DummyCellCollector {
fn collect_live_cells(
&mut self,
_query: &CellQueryOptions,
_apply_changes: bool,
) -> Result<(Vec<LiveCell>, u64), CellCollectorError> {
Err(CellCollectorError::Other(anyhow!(
"dummy collect_live_cells"
)))
}
fn lock_cell(&mut self, _out_point: OutPoint) -> Result<(), CellCollectorError> {
Err(CellCollectorError::Other(anyhow!("dummy lock_cell")))
}
fn apply_tx(&mut self, _tx: Transaction) -> Result<(), CellCollectorError> {
Err(CellCollectorError::Other(anyhow!("dummy apply_tx")))
}
fn reset(&mut self) {}
}
#[derive(Default)]
pub struct DummyHeaderDepResolver;
impl HeaderDepResolver for DummyHeaderDepResolver {
fn resolve_by_tx(&self, _tx_hash: &Byte32) -> Result<Option<HeaderView>, anyhow::Error> {
Err(anyhow!("dummy resolve_by_tx"))
}
fn resolve_by_number(&self, _number: u64) -> Result<Option<HeaderView>, anyhow::Error> {
Err(anyhow!("dummy resolve_by_number"))
}
}
#[derive(Default)]
pub struct DummyTransactionDependencyProvider;
impl TransactionDependencyProvider for DummyTransactionDependencyProvider {
fn get_transaction(
&self,
_tx_hash: &Byte32,
) -> Result<TransactionView, TransactionDependencyError> {
Err(TransactionDependencyError::Other(anyhow!(
"dummy get_transaction"
)))
}
fn get_cell(&self, _out_point: &OutPoint) -> Result<CellOutput, TransactionDependencyError> {
Err(TransactionDependencyError::Other(anyhow!("dummy get_cell")))
}
fn get_cell_data(&self, _out_point: &OutPoint) -> Result<Bytes, TransactionDependencyError> {
Err(TransactionDependencyError::Other(anyhow!(
"dummy get_cell_data"
)))
}
fn get_header(&self, _block_hash: &Byte32) -> Result<HeaderView, TransactionDependencyError> {
Err(TransactionDependencyError::Other(anyhow!(
"dummy get_header"
)))
}
}