mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-23 17:08:10 -07:00
computer: store part 3
This commit is contained in:
+317
-105
@@ -1,12 +1,13 @@
|
||||
use std::{path::Path, thread};
|
||||
|
||||
use brk_core::{
|
||||
AddressData, EmptyAddressData, Height, P2AAddressIndex, P2AAddressIndexOutputindex,
|
||||
P2PK33AddressIndex, P2PK33AddressIndexOutputindex, P2PK65AddressIndex,
|
||||
P2PK65AddressIndexOutputindex, P2PKHAddressIndex, P2PKHAddressIndexOutputindex,
|
||||
P2SHAddressIndex, P2SHAddressIndexOutputindex, P2TRAddressIndex, P2TRAddressIndexOutputindex,
|
||||
P2WPKHAddressIndex, P2WPKHAddressIndexOutputindex, P2WSHAddressIndex,
|
||||
P2WSHAddressIndexOutputindex, Result, Unit, Version,
|
||||
AddressData, AddressIndexToTypeIndedToOutputIndex, EmptyAddressData, GroupedByAddressType,
|
||||
Height, P2AAddressIndex, P2AAddressIndexOutputindex, P2PK33AddressIndex,
|
||||
P2PK33AddressIndexOutputindex, P2PK65AddressIndex, P2PK65AddressIndexOutputindex,
|
||||
P2PKHAddressIndex, P2PKHAddressIndexOutputindex, P2SHAddressIndex, P2SHAddressIndexOutputindex,
|
||||
P2TRAddressIndex, P2TRAddressIndexOutputindex, P2WPKHAddressIndex,
|
||||
P2WPKHAddressIndexOutputindex, P2WSHAddressIndex, P2WSHAddressIndexOutputindex, Result, Unit,
|
||||
Version,
|
||||
};
|
||||
use brk_store::{AnyStore, Store};
|
||||
use fjall::{PersistMode, TransactionalKeyspace};
|
||||
@@ -20,43 +21,43 @@ pub struct Stores {
|
||||
|
||||
pub p2aaddressindex_to_addressdata: Store<P2AAddressIndex, AddressData>,
|
||||
pub p2aaddressindex_to_emptyaddressdata: Store<P2AAddressIndex, EmptyAddressData>,
|
||||
pub p2aaddressindex_to_utxos_received: Store<P2AAddressIndexOutputindex, Unit>,
|
||||
pub p2aaddressindex_to_utxos_sent: Store<P2AAddressIndexOutputindex, Unit>,
|
||||
pub p2aaddressindex_to_outputs_received: Store<P2AAddressIndexOutputindex, Unit>,
|
||||
pub p2aaddressindex_to_outputs_sent: Store<P2AAddressIndexOutputindex, Unit>,
|
||||
|
||||
pub p2pk33addressindex_to_addressdata: Store<P2PK33AddressIndex, AddressData>,
|
||||
pub p2pk33addressindex_to_emptyaddressdata: Store<P2PK33AddressIndex, EmptyAddressData>,
|
||||
pub p2pk33addressindex_to_utxos_received: Store<P2PK33AddressIndexOutputindex, Unit>,
|
||||
pub p2pk33addressindex_to_utxos_sent: Store<P2PK33AddressIndexOutputindex, Unit>,
|
||||
pub p2pk33addressindex_to_outputs_received: Store<P2PK33AddressIndexOutputindex, Unit>,
|
||||
pub p2pk33addressindex_to_outputs_sent: Store<P2PK33AddressIndexOutputindex, Unit>,
|
||||
|
||||
pub p2pk65addressindex_to_addressdata: Store<P2PK65AddressIndex, AddressData>,
|
||||
pub p2pk65addressindex_to_emptyaddressdata: Store<P2PK65AddressIndex, EmptyAddressData>,
|
||||
pub p2pk65addressindex_to_utxos_received: Store<P2PK65AddressIndexOutputindex, Unit>,
|
||||
pub p2pk65addressindex_to_utxos_sent: Store<P2PK65AddressIndexOutputindex, Unit>,
|
||||
pub p2pk65addressindex_to_outputs_received: Store<P2PK65AddressIndexOutputindex, Unit>,
|
||||
pub p2pk65addressindex_to_outputs_sent: Store<P2PK65AddressIndexOutputindex, Unit>,
|
||||
|
||||
pub p2pkhaddressindex_to_addressdata: Store<P2PKHAddressIndex, AddressData>,
|
||||
pub p2pkhaddressindex_to_emptyaddressdata: Store<P2PKHAddressIndex, EmptyAddressData>,
|
||||
pub p2pkhaddressindex_to_utxos_received: Store<P2PKHAddressIndexOutputindex, Unit>,
|
||||
pub p2pkhaddressindex_to_utxos_sent: Store<P2PKHAddressIndexOutputindex, Unit>,
|
||||
pub p2pkhaddressindex_to_outputs_received: Store<P2PKHAddressIndexOutputindex, Unit>,
|
||||
pub p2pkhaddressindex_to_outputs_sent: Store<P2PKHAddressIndexOutputindex, Unit>,
|
||||
|
||||
pub p2shaddressindex_to_addressdata: Store<P2SHAddressIndex, AddressData>,
|
||||
pub p2shaddressindex_to_emptyaddressdata: Store<P2SHAddressIndex, EmptyAddressData>,
|
||||
pub p2shaddressindex_to_utxos_received: Store<P2SHAddressIndexOutputindex, Unit>,
|
||||
pub p2shaddressindex_to_utxos_sent: Store<P2SHAddressIndexOutputindex, Unit>,
|
||||
pub p2shaddressindex_to_outputs_received: Store<P2SHAddressIndexOutputindex, Unit>,
|
||||
pub p2shaddressindex_to_outputs_sent: Store<P2SHAddressIndexOutputindex, Unit>,
|
||||
|
||||
pub p2traddressindex_to_addressdata: Store<P2TRAddressIndex, AddressData>,
|
||||
pub p2traddressindex_to_emptyaddressdata: Store<P2TRAddressIndex, EmptyAddressData>,
|
||||
pub p2traddressindex_to_utxos_received: Store<P2TRAddressIndexOutputindex, Unit>,
|
||||
pub p2traddressindex_to_utxos_sent: Store<P2TRAddressIndexOutputindex, Unit>,
|
||||
pub p2traddressindex_to_outputs_received: Store<P2TRAddressIndexOutputindex, Unit>,
|
||||
pub p2traddressindex_to_outputs_sent: Store<P2TRAddressIndexOutputindex, Unit>,
|
||||
|
||||
pub p2wpkhaddressindex_to_addressdata: Store<P2WPKHAddressIndex, AddressData>,
|
||||
pub p2wpkhaddressindex_to_emptyaddressdata: Store<P2WPKHAddressIndex, EmptyAddressData>,
|
||||
pub p2wpkhaddressindex_to_utxos_received: Store<P2WPKHAddressIndexOutputindex, Unit>,
|
||||
pub p2wpkhaddressindex_to_utxos_sent: Store<P2WPKHAddressIndexOutputindex, Unit>,
|
||||
pub p2wpkhaddressindex_to_outputs_received: Store<P2WPKHAddressIndexOutputindex, Unit>,
|
||||
pub p2wpkhaddressindex_to_outputs_sent: Store<P2WPKHAddressIndexOutputindex, Unit>,
|
||||
|
||||
pub p2wshaddressindex_to_addressdata: Store<P2WSHAddressIndex, AddressData>,
|
||||
pub p2wshaddressindex_to_emptyaddressdata: Store<P2WSHAddressIndex, EmptyAddressData>,
|
||||
pub p2wshaddressindex_to_utxos_received: Store<P2WSHAddressIndexOutputindex, Unit>,
|
||||
pub p2wshaddressindex_to_utxos_sent: Store<P2WSHAddressIndexOutputindex, Unit>,
|
||||
pub p2wshaddressindex_to_outputs_received: Store<P2WSHAddressIndexOutputindex, Unit>,
|
||||
pub p2wshaddressindex_to_outputs_sent: Store<P2WSHAddressIndexOutputindex, Unit>,
|
||||
}
|
||||
|
||||
impl Stores {
|
||||
@@ -69,50 +70,50 @@ impl Stores {
|
||||
(
|
||||
p2aaddressindex_to_addressdata,
|
||||
p2aaddressindex_to_emptyaddressdata,
|
||||
p2aaddressindex_to_utxos_received,
|
||||
p2aaddressindex_to_utxos_sent,
|
||||
p2aaddressindex_to_outputs_received,
|
||||
p2aaddressindex_to_outputs_sent,
|
||||
),
|
||||
(
|
||||
p2pk33addressindex_to_addressdata,
|
||||
p2pk33addressindex_to_emptyaddressdata,
|
||||
p2pk33addressindex_to_utxos_received,
|
||||
p2pk33addressindex_to_utxos_sent,
|
||||
p2pk33addressindex_to_outputs_received,
|
||||
p2pk33addressindex_to_outputs_sent,
|
||||
),
|
||||
(
|
||||
p2pk65addressindex_to_addressdata,
|
||||
p2pk65addressindex_to_emptyaddressdata,
|
||||
p2pk65addressindex_to_utxos_received,
|
||||
p2pk65addressindex_to_utxos_sent,
|
||||
p2pk65addressindex_to_outputs_received,
|
||||
p2pk65addressindex_to_outputs_sent,
|
||||
),
|
||||
(
|
||||
p2pkhaddressindex_to_addressdata,
|
||||
p2pkhaddressindex_to_emptyaddressdata,
|
||||
p2pkhaddressindex_to_utxos_received,
|
||||
p2pkhaddressindex_to_utxos_sent,
|
||||
p2pkhaddressindex_to_outputs_received,
|
||||
p2pkhaddressindex_to_outputs_sent,
|
||||
),
|
||||
(
|
||||
p2shaddressindex_to_addressdata,
|
||||
p2shaddressindex_to_emptyaddressdata,
|
||||
p2shaddressindex_to_utxos_received,
|
||||
p2shaddressindex_to_utxos_sent,
|
||||
p2shaddressindex_to_outputs_received,
|
||||
p2shaddressindex_to_outputs_sent,
|
||||
),
|
||||
(
|
||||
p2traddressindex_to_addressdata,
|
||||
p2traddressindex_to_emptyaddressdata,
|
||||
p2traddressindex_to_utxos_received,
|
||||
p2traddressindex_to_utxos_sent,
|
||||
p2traddressindex_to_outputs_received,
|
||||
p2traddressindex_to_outputs_sent,
|
||||
),
|
||||
(
|
||||
p2wpkhaddressindex_to_addressdata,
|
||||
p2wpkhaddressindex_to_emptyaddressdata,
|
||||
p2wpkhaddressindex_to_utxos_received,
|
||||
p2wpkhaddressindex_to_utxos_sent,
|
||||
p2wpkhaddressindex_to_outputs_received,
|
||||
p2wpkhaddressindex_to_outputs_sent,
|
||||
),
|
||||
(
|
||||
p2wshaddressindex_to_addressdata,
|
||||
p2wshaddressindex_to_emptyaddressdata,
|
||||
p2wshaddressindex_to_utxos_received,
|
||||
p2wshaddressindex_to_utxos_sent,
|
||||
p2wshaddressindex_to_outputs_received,
|
||||
p2wshaddressindex_to_outputs_sent,
|
||||
),
|
||||
) = thread::scope(|scope| {
|
||||
let p2a = scope.spawn(|| {
|
||||
@@ -136,7 +137,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2aaddressindex_to_utxos_received",
|
||||
"p2aaddressindex_to_outputs_received",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -144,7 +145,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2aaddressindex_to_utxos_sent",
|
||||
"p2aaddressindex_to_outputs_sent",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -173,7 +174,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2pk33addressindex_to_utxos_received",
|
||||
"p2pk33addressindex_to_outputs_received",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -181,7 +182,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2pk33addressindex_to_utxos_sent",
|
||||
"p2pk33addressindex_to_outputs_sent",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -210,7 +211,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2pk65addressindex_to_utxos_received",
|
||||
"p2pk65addressindex_to_outputs_received",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -218,7 +219,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2pk65addressindex_to_utxos_sent",
|
||||
"p2pk65addressindex_to_outputs_sent",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -247,7 +248,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2pkhaddressindex_to_utxos_received",
|
||||
"p2pkhaddressindex_to_outputs_received",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -255,7 +256,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2pkhaddressindex_to_utxos_sent",
|
||||
"p2pkhaddressindex_to_outputs_sent",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -284,7 +285,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2shaddressindex_to_utxos_received",
|
||||
"p2shaddressindex_to_outputs_received",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -292,7 +293,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2shaddressindex_to_utxos_sent",
|
||||
"p2shaddressindex_to_outputs_sent",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -321,7 +322,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2traddressindex_to_utxos_received",
|
||||
"p2traddressindex_to_outputs_received",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -329,7 +330,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2traddressindex_to_utxos_sent",
|
||||
"p2traddressindex_to_outputs_sent",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -358,7 +359,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2wpkhaddressindex_to_utxos_received",
|
||||
"p2wpkhaddressindex_to_outputs_received",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -366,7 +367,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2wpkhaddressindex_to_utxos_sent",
|
||||
"p2wpkhaddressindex_to_outputs_sent",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -395,7 +396,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2wshaddressindex_to_utxos_received",
|
||||
"p2wshaddressindex_to_outputs_received",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -403,7 +404,7 @@ impl Stores {
|
||||
Store::import(
|
||||
keyspace,
|
||||
path,
|
||||
"p2wshaddressindex_to_utxos_sent",
|
||||
"p2wshaddressindex_to_outputs_sent",
|
||||
version + VERSION + Version::ZERO,
|
||||
None,
|
||||
)
|
||||
@@ -428,43 +429,43 @@ impl Stores {
|
||||
|
||||
p2aaddressindex_to_addressdata,
|
||||
p2aaddressindex_to_emptyaddressdata,
|
||||
p2aaddressindex_to_utxos_received,
|
||||
p2aaddressindex_to_utxos_sent,
|
||||
p2aaddressindex_to_outputs_received,
|
||||
p2aaddressindex_to_outputs_sent,
|
||||
|
||||
p2pk33addressindex_to_addressdata,
|
||||
p2pk33addressindex_to_emptyaddressdata,
|
||||
p2pk33addressindex_to_utxos_received,
|
||||
p2pk33addressindex_to_utxos_sent,
|
||||
p2pk33addressindex_to_outputs_received,
|
||||
p2pk33addressindex_to_outputs_sent,
|
||||
|
||||
p2pk65addressindex_to_addressdata,
|
||||
p2pk65addressindex_to_emptyaddressdata,
|
||||
p2pk65addressindex_to_utxos_received,
|
||||
p2pk65addressindex_to_utxos_sent,
|
||||
p2pk65addressindex_to_outputs_received,
|
||||
p2pk65addressindex_to_outputs_sent,
|
||||
|
||||
p2pkhaddressindex_to_addressdata,
|
||||
p2pkhaddressindex_to_emptyaddressdata,
|
||||
p2pkhaddressindex_to_utxos_received,
|
||||
p2pkhaddressindex_to_utxos_sent,
|
||||
p2pkhaddressindex_to_outputs_received,
|
||||
p2pkhaddressindex_to_outputs_sent,
|
||||
|
||||
p2shaddressindex_to_addressdata,
|
||||
p2shaddressindex_to_emptyaddressdata,
|
||||
p2shaddressindex_to_utxos_received,
|
||||
p2shaddressindex_to_utxos_sent,
|
||||
p2shaddressindex_to_outputs_received,
|
||||
p2shaddressindex_to_outputs_sent,
|
||||
|
||||
p2traddressindex_to_addressdata,
|
||||
p2traddressindex_to_emptyaddressdata,
|
||||
p2traddressindex_to_utxos_received,
|
||||
p2traddressindex_to_utxos_sent,
|
||||
p2traddressindex_to_outputs_received,
|
||||
p2traddressindex_to_outputs_sent,
|
||||
|
||||
p2wpkhaddressindex_to_addressdata,
|
||||
p2wpkhaddressindex_to_emptyaddressdata,
|
||||
p2wpkhaddressindex_to_utxos_received,
|
||||
p2wpkhaddressindex_to_utxos_sent,
|
||||
p2wpkhaddressindex_to_outputs_received,
|
||||
p2wpkhaddressindex_to_outputs_sent,
|
||||
|
||||
p2wshaddressindex_to_addressdata,
|
||||
p2wshaddressindex_to_emptyaddressdata,
|
||||
p2wshaddressindex_to_utxos_received,
|
||||
p2wshaddressindex_to_utxos_sent,
|
||||
p2wshaddressindex_to_outputs_received,
|
||||
p2wshaddressindex_to_outputs_sent,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -476,10 +477,221 @@ impl Stores {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn commit(&mut self, height: Height) -> Result<()> {
|
||||
pub fn reset(&mut self) -> Result<()> {
|
||||
self.as_mut_slice()
|
||||
.into_par_iter()
|
||||
.try_for_each(|store| store.commit(height))?;
|
||||
.try_for_each(|store| store.reset())?;
|
||||
|
||||
self.keyspace
|
||||
.persist(PersistMode::SyncAll)
|
||||
.map_err(|e| e.into())
|
||||
}
|
||||
|
||||
pub fn commit(
|
||||
&mut self,
|
||||
height: Height,
|
||||
sent: AddressIndexToTypeIndedToOutputIndex,
|
||||
received: AddressIndexToTypeIndedToOutputIndex,
|
||||
) -> Result<()> {
|
||||
// &mut self.p2aaddressindex_to_addressdata,
|
||||
// &mut self.p2pk33addressindex_to_addressdata,
|
||||
// &mut self.p2pk65addressindex_to_addressdata,
|
||||
// &mut self.p2pkhaddressindex_to_addressdata,
|
||||
// &mut self.p2shaddressindex_to_addressdata,
|
||||
// &mut self.p2traddressindex_to_addressdata,
|
||||
// &mut self.p2wpkhaddressindex_to_addressdata,
|
||||
// &mut self.p2wshaddressindex_to_addressdata,
|
||||
|
||||
// &mut self.p2aaddressindex_to_emptyaddressdata,
|
||||
// &mut self.p2pk33addressindex_to_emptyaddressdata,
|
||||
// &mut self.p2pk65addressindex_to_emptyaddressdata,
|
||||
// &mut self.p2pkhaddressindex_to_emptyaddressdata,
|
||||
// &mut self.p2shaddressindex_to_emptyaddressdata,
|
||||
// &mut self.p2traddressindex_to_emptyaddressdata,
|
||||
// &mut self.p2wpkhaddressindex_to_emptyaddressdata,
|
||||
// &mut self.p2wshaddressindex_to_emptyaddressdata,
|
||||
|
||||
thread::scope(|s| {
|
||||
let GroupedByAddressType {
|
||||
p2pk65,
|
||||
p2pk33,
|
||||
p2pkh,
|
||||
p2sh,
|
||||
p2wpkh,
|
||||
p2wsh,
|
||||
p2tr,
|
||||
p2a,
|
||||
} = received.inner();
|
||||
|
||||
s.spawn(|| {
|
||||
self.p2aaddressindex_to_outputs_received.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2a.into_iter()
|
||||
.map(P2AAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2pk33addressindex_to_outputs_received.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2pk33
|
||||
.into_iter()
|
||||
.map(P2PK33AddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2pk65addressindex_to_outputs_received.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2pk65
|
||||
.into_iter()
|
||||
.map(P2PK65AddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2pkhaddressindex_to_outputs_received.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2pkh
|
||||
.into_iter()
|
||||
.map(P2PKHAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2shaddressindex_to_outputs_received.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2sh.into_iter()
|
||||
.map(P2SHAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2traddressindex_to_outputs_received.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2tr.into_iter()
|
||||
.map(P2TRAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2wpkhaddressindex_to_outputs_received.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2wpkh
|
||||
.into_iter()
|
||||
.map(P2WPKHAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2wshaddressindex_to_outputs_received.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2wsh
|
||||
.into_iter()
|
||||
.map(P2WSHAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
thread::scope(|s| {
|
||||
let GroupedByAddressType {
|
||||
p2pk65,
|
||||
p2pk33,
|
||||
p2pkh,
|
||||
p2sh,
|
||||
p2wpkh,
|
||||
p2wsh,
|
||||
p2tr,
|
||||
p2a,
|
||||
} = sent.inner();
|
||||
|
||||
s.spawn(|| {
|
||||
self.p2aaddressindex_to_outputs_sent.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2a.into_iter()
|
||||
.map(P2AAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2pk33addressindex_to_outputs_sent.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2pk33
|
||||
.into_iter()
|
||||
.map(P2PK33AddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2pk65addressindex_to_outputs_sent.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2pk65
|
||||
.into_iter()
|
||||
.map(P2PK65AddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2pkhaddressindex_to_outputs_sent.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2pkh
|
||||
.into_iter()
|
||||
.map(P2PKHAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2shaddressindex_to_outputs_sent.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2sh.into_iter()
|
||||
.map(P2SHAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2traddressindex_to_outputs_sent.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2tr.into_iter()
|
||||
.map(P2TRAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2wpkhaddressindex_to_outputs_sent.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2wpkh
|
||||
.into_iter()
|
||||
.map(P2WPKHAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
s.spawn(|| {
|
||||
self.p2wshaddressindex_to_outputs_sent.commit_(
|
||||
height,
|
||||
[].into_iter(),
|
||||
p2wsh
|
||||
.into_iter()
|
||||
.map(P2WSHAddressIndexOutputindex::from)
|
||||
.map(|i| (i, Unit)),
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
self.keyspace
|
||||
.persist(PersistMode::SyncAll)
|
||||
@@ -492,40 +704,40 @@ impl Stores {
|
||||
.for_each(|store| store.rotate_memtable());
|
||||
}
|
||||
|
||||
fn as_slice(&self) -> [&(dyn AnyStore + Send + Sync); 32] {
|
||||
pub fn as_slice(&self) -> [&(dyn AnyStore + Send + Sync); 32] {
|
||||
[
|
||||
&self.p2aaddressindex_to_addressdata,
|
||||
&self.p2aaddressindex_to_emptyaddressdata,
|
||||
&self.p2aaddressindex_to_utxos_received,
|
||||
&self.p2aaddressindex_to_utxos_sent,
|
||||
&self.p2aaddressindex_to_outputs_received,
|
||||
&self.p2aaddressindex_to_outputs_sent,
|
||||
&self.p2pk33addressindex_to_addressdata,
|
||||
&self.p2pk33addressindex_to_emptyaddressdata,
|
||||
&self.p2pk33addressindex_to_utxos_received,
|
||||
&self.p2pk33addressindex_to_utxos_sent,
|
||||
&self.p2pk33addressindex_to_outputs_received,
|
||||
&self.p2pk33addressindex_to_outputs_sent,
|
||||
&self.p2pk65addressindex_to_addressdata,
|
||||
&self.p2pk65addressindex_to_emptyaddressdata,
|
||||
&self.p2pk65addressindex_to_utxos_received,
|
||||
&self.p2pk65addressindex_to_utxos_sent,
|
||||
&self.p2pk65addressindex_to_outputs_received,
|
||||
&self.p2pk65addressindex_to_outputs_sent,
|
||||
&self.p2pkhaddressindex_to_addressdata,
|
||||
&self.p2pkhaddressindex_to_emptyaddressdata,
|
||||
&self.p2pkhaddressindex_to_utxos_received,
|
||||
&self.p2pkhaddressindex_to_utxos_sent,
|
||||
&self.p2pkhaddressindex_to_outputs_received,
|
||||
&self.p2pkhaddressindex_to_outputs_sent,
|
||||
&self.p2shaddressindex_to_addressdata,
|
||||
&self.p2shaddressindex_to_emptyaddressdata,
|
||||
&self.p2shaddressindex_to_utxos_received,
|
||||
&self.p2shaddressindex_to_utxos_sent,
|
||||
&self.p2shaddressindex_to_outputs_received,
|
||||
&self.p2shaddressindex_to_outputs_sent,
|
||||
&self.p2traddressindex_to_addressdata,
|
||||
&self.p2traddressindex_to_emptyaddressdata,
|
||||
&self.p2traddressindex_to_utxos_received,
|
||||
&self.p2traddressindex_to_utxos_sent,
|
||||
&self.p2traddressindex_to_outputs_received,
|
||||
&self.p2traddressindex_to_outputs_sent,
|
||||
&self.p2wpkhaddressindex_to_addressdata,
|
||||
&self.p2wpkhaddressindex_to_emptyaddressdata,
|
||||
&self.p2wpkhaddressindex_to_utxos_received,
|
||||
&self.p2wpkhaddressindex_to_utxos_sent,
|
||||
&self.p2wpkhaddressindex_to_outputs_received,
|
||||
&self.p2wpkhaddressindex_to_outputs_sent,
|
||||
&self.p2wshaddressindex_to_addressdata,
|
||||
&self.p2wshaddressindex_to_emptyaddressdata,
|
||||
&self.p2wshaddressindex_to_utxos_received,
|
||||
&self.p2wshaddressindex_to_utxos_sent,
|
||||
&self.p2wshaddressindex_to_outputs_received,
|
||||
&self.p2wshaddressindex_to_outputs_sent,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -533,36 +745,36 @@ impl Stores {
|
||||
[
|
||||
&mut self.p2aaddressindex_to_addressdata,
|
||||
&mut self.p2aaddressindex_to_emptyaddressdata,
|
||||
&mut self.p2aaddressindex_to_utxos_received,
|
||||
&mut self.p2aaddressindex_to_utxos_sent,
|
||||
&mut self.p2aaddressindex_to_outputs_received,
|
||||
&mut self.p2aaddressindex_to_outputs_sent,
|
||||
&mut self.p2pk33addressindex_to_addressdata,
|
||||
&mut self.p2pk33addressindex_to_emptyaddressdata,
|
||||
&mut self.p2pk33addressindex_to_utxos_received,
|
||||
&mut self.p2pk33addressindex_to_utxos_sent,
|
||||
&mut self.p2pk33addressindex_to_outputs_received,
|
||||
&mut self.p2pk33addressindex_to_outputs_sent,
|
||||
&mut self.p2pk65addressindex_to_addressdata,
|
||||
&mut self.p2pk65addressindex_to_emptyaddressdata,
|
||||
&mut self.p2pk65addressindex_to_utxos_received,
|
||||
&mut self.p2pk65addressindex_to_utxos_sent,
|
||||
&mut self.p2pk65addressindex_to_outputs_received,
|
||||
&mut self.p2pk65addressindex_to_outputs_sent,
|
||||
&mut self.p2pkhaddressindex_to_addressdata,
|
||||
&mut self.p2pkhaddressindex_to_emptyaddressdata,
|
||||
&mut self.p2pkhaddressindex_to_utxos_received,
|
||||
&mut self.p2pkhaddressindex_to_utxos_sent,
|
||||
&mut self.p2pkhaddressindex_to_outputs_received,
|
||||
&mut self.p2pkhaddressindex_to_outputs_sent,
|
||||
&mut self.p2shaddressindex_to_addressdata,
|
||||
&mut self.p2shaddressindex_to_emptyaddressdata,
|
||||
&mut self.p2shaddressindex_to_utxos_received,
|
||||
&mut self.p2shaddressindex_to_utxos_sent,
|
||||
&mut self.p2shaddressindex_to_outputs_received,
|
||||
&mut self.p2shaddressindex_to_outputs_sent,
|
||||
&mut self.p2traddressindex_to_addressdata,
|
||||
&mut self.p2traddressindex_to_emptyaddressdata,
|
||||
&mut self.p2traddressindex_to_utxos_received,
|
||||
&mut self.p2traddressindex_to_utxos_sent,
|
||||
&mut self.p2traddressindex_to_outputs_received,
|
||||
&mut self.p2traddressindex_to_outputs_sent,
|
||||
&mut self.p2wpkhaddressindex_to_addressdata,
|
||||
&mut self.p2wpkhaddressindex_to_emptyaddressdata,
|
||||
&mut self.p2wpkhaddressindex_to_utxos_received,
|
||||
&mut self.p2wpkhaddressindex_to_utxos_sent,
|
||||
&mut self.p2wpkhaddressindex_to_outputs_received,
|
||||
&mut self.p2wpkhaddressindex_to_outputs_sent,
|
||||
&mut self.p2wshaddressindex_to_addressdata,
|
||||
&mut self.p2wshaddressindex_to_emptyaddressdata,
|
||||
&mut self.p2wshaddressindex_to_utxos_received,
|
||||
&mut self.p2wshaddressindex_to_utxos_sent,
|
||||
&mut self.p2wshaddressindex_to_outputs_received,
|
||||
&mut self.p2wshaddressindex_to_outputs_sent,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user