mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-08 14:11:56 -07:00
global: wip + fixed eager mode
This commit is contained in:
@@ -94,7 +94,7 @@ Heartfelt thanks go out to every donor on [Nostr](https://primal.net/p/npub1jagm
|
||||
If you'd like to have your own instance hosted for you please contact [hosting@bitcoinresearchkit.org](mailto:hosting@bitcoinresearchkit.org).
|
||||
|
||||
- 2 separate dedicated servers (1 GB/s each) with different ISPs and Cloudflare integration for enhanced performance and optimal availability
|
||||
- 99.9% SLA
|
||||
- 99.99% SLA
|
||||
- Configurated for speed (`raw + eager`)
|
||||
- Updates delivered at your convenience
|
||||
- Direct communication for feature requests and support
|
||||
|
||||
@@ -207,6 +207,8 @@ where
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
self.validate_computed_version_or_reset_file(source.version())?;
|
||||
|
||||
let index = self.starting_index(max_from);
|
||||
|
||||
let cumulative_vec = self.cumulative.as_mut().unwrap();
|
||||
|
||||
@@ -5,7 +5,7 @@ use brk_core::{
|
||||
InputIndex, MonthIndex, OpReturnIndex, OutputIndex, P2ABytes, P2AIndex, P2MSIndex, P2PK33Bytes,
|
||||
P2PK33Index, P2PK65Bytes, P2PK65Index, P2PKHBytes, P2PKHIndex, P2SHBytes, P2SHIndex, P2TRBytes,
|
||||
P2TRIndex, P2WPKHBytes, P2WPKHIndex, P2WSHBytes, P2WSHIndex, QuarterIndex, Sats, StoredUsize,
|
||||
Timestamp, TxIndex, Txid, UnknownOutputIndex, Version, WeekIndex, Weight, YearIndex,
|
||||
Timestamp, TxIndex, Txid, UnknownOutputIndex, Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use brk_exit::Exit;
|
||||
use brk_indexer::Indexer;
|
||||
@@ -20,40 +20,36 @@ const VERSION: Version = Version::ZERO;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Vecs {
|
||||
pub dateindex_to_date: ComputedVecFrom1<DateIndex, Date, DateIndex, DateIndex>,
|
||||
pub dateindex_to_dateindex: ComputedVecFrom1<DateIndex, DateIndex, DateIndex, Height>,
|
||||
pub dateindex_to_date: EagerVec<DateIndex, Date>,
|
||||
pub dateindex_to_dateindex: EagerVec<DateIndex, DateIndex>,
|
||||
pub dateindex_to_first_height: EagerVec<DateIndex, Height>,
|
||||
pub dateindex_to_height_count: EagerVec<DateIndex, StoredUsize>,
|
||||
pub dateindex_to_monthindex: EagerVec<DateIndex, MonthIndex>,
|
||||
pub dateindex_to_weekindex: EagerVec<DateIndex, WeekIndex>,
|
||||
pub decadeindex_to_decadeindex:
|
||||
ComputedVecFrom1<DecadeIndex, DecadeIndex, DecadeIndex, YearIndex>,
|
||||
pub decadeindex_to_decadeindex: EagerVec<DecadeIndex, DecadeIndex>,
|
||||
pub decadeindex_to_first_yearindex: EagerVec<DecadeIndex, YearIndex>,
|
||||
pub decadeindex_to_yearindex_count: EagerVec<DecadeIndex, StoredUsize>,
|
||||
pub difficultyepoch_to_difficultyepoch:
|
||||
ComputedVecFrom1<DifficultyEpoch, DifficultyEpoch, DifficultyEpoch, Height>,
|
||||
pub difficultyepoch_to_difficultyepoch: EagerVec<DifficultyEpoch, DifficultyEpoch>,
|
||||
pub difficultyepoch_to_first_height: EagerVec<DifficultyEpoch, Height>,
|
||||
pub difficultyepoch_to_height_count: EagerVec<DifficultyEpoch, StoredUsize>,
|
||||
pub emptyoutputindex_to_emptyoutputindex:
|
||||
ComputedVecFrom1<EmptyOutputIndex, EmptyOutputIndex, EmptyOutputIndex, TxIndex>,
|
||||
pub halvingepoch_to_first_height: EagerVec<HalvingEpoch, Height>,
|
||||
pub halvingepoch_to_halvingepoch:
|
||||
ComputedVecFrom1<HalvingEpoch, HalvingEpoch, HalvingEpoch, Height>,
|
||||
pub halvingepoch_to_halvingepoch: EagerVec<HalvingEpoch, HalvingEpoch>,
|
||||
pub height_to_date: EagerVec<Height, Date>,
|
||||
pub height_to_date_fixed: EagerVec<Height, Date>,
|
||||
pub height_to_dateindex: EagerVec<Height, DateIndex>,
|
||||
pub height_to_difficultyepoch: ComputedVecFrom1<Height, DifficultyEpoch, Height, Height>,
|
||||
pub height_to_halvingepoch: ComputedVecFrom1<Height, HalvingEpoch, Height, Height>,
|
||||
pub height_to_height: ComputedVecFrom1<Height, Height, Height, Weight>,
|
||||
pub height_to_difficultyepoch: EagerVec<Height, DifficultyEpoch>,
|
||||
pub height_to_halvingepoch: EagerVec<Height, HalvingEpoch>,
|
||||
pub height_to_height: EagerVec<Height, Height>,
|
||||
pub height_to_timestamp_fixed: EagerVec<Height, Timestamp>,
|
||||
pub height_to_txindex_count: EagerVec<Height, StoredUsize>,
|
||||
pub inputindex_to_inputindex: ComputedVecFrom1<InputIndex, InputIndex, InputIndex, OutputIndex>,
|
||||
pub monthindex_to_dateindex_count: EagerVec<MonthIndex, StoredUsize>,
|
||||
pub monthindex_to_first_dateindex: EagerVec<MonthIndex, DateIndex>,
|
||||
pub monthindex_to_monthindex: ComputedVecFrom1<MonthIndex, MonthIndex, MonthIndex, DateIndex>,
|
||||
pub monthindex_to_quarterindex:
|
||||
ComputedVecFrom1<MonthIndex, QuarterIndex, MonthIndex, MonthIndex>,
|
||||
pub monthindex_to_yearindex: ComputedVecFrom1<MonthIndex, YearIndex, MonthIndex, MonthIndex>,
|
||||
pub monthindex_to_monthindex: EagerVec<MonthIndex, MonthIndex>,
|
||||
pub monthindex_to_quarterindex: EagerVec<MonthIndex, QuarterIndex>,
|
||||
pub monthindex_to_yearindex: EagerVec<MonthIndex, YearIndex>,
|
||||
pub opreturnindex_to_opreturnindex:
|
||||
ComputedVecFrom1<OpReturnIndex, OpReturnIndex, OpReturnIndex, TxIndex>,
|
||||
pub outputindex_to_outputindex: ComputedVecFrom1<OutputIndex, OutputIndex, OutputIndex, Sats>,
|
||||
@@ -72,8 +68,7 @@ pub struct Vecs {
|
||||
pub p2wshindex_to_p2wshindex: ComputedVecFrom1<P2WSHIndex, P2WSHIndex, P2WSHIndex, P2WSHBytes>,
|
||||
pub quarterindex_to_first_monthindex: EagerVec<QuarterIndex, MonthIndex>,
|
||||
pub quarterindex_to_monthindex_count: EagerVec<QuarterIndex, StoredUsize>,
|
||||
pub quarterindex_to_quarterindex:
|
||||
ComputedVecFrom1<QuarterIndex, QuarterIndex, QuarterIndex, MonthIndex>,
|
||||
pub quarterindex_to_quarterindex: EagerVec<QuarterIndex, QuarterIndex>,
|
||||
pub txindex_to_height: EagerVec<TxIndex, Height>,
|
||||
pub txindex_to_input_count:
|
||||
ComputedVecFrom2<TxIndex, StoredUsize, TxIndex, InputIndex, InputIndex, OutputIndex>,
|
||||
@@ -84,11 +79,11 @@ pub struct Vecs {
|
||||
ComputedVecFrom1<UnknownOutputIndex, UnknownOutputIndex, UnknownOutputIndex, TxIndex>,
|
||||
pub weekindex_to_dateindex_count: EagerVec<WeekIndex, StoredUsize>,
|
||||
pub weekindex_to_first_dateindex: EagerVec<WeekIndex, DateIndex>,
|
||||
pub weekindex_to_weekindex: ComputedVecFrom1<WeekIndex, WeekIndex, WeekIndex, DateIndex>,
|
||||
pub yearindex_to_decadeindex: ComputedVecFrom1<YearIndex, DecadeIndex, YearIndex, YearIndex>,
|
||||
pub weekindex_to_weekindex: EagerVec<WeekIndex, WeekIndex>,
|
||||
pub yearindex_to_decadeindex: EagerVec<YearIndex, DecadeIndex>,
|
||||
pub yearindex_to_first_monthindex: EagerVec<YearIndex, MonthIndex>,
|
||||
pub yearindex_to_monthindex_count: EagerVec<YearIndex, StoredUsize>,
|
||||
pub yearindex_to_yearindex: ComputedVecFrom1<YearIndex, YearIndex, YearIndex, MonthIndex>,
|
||||
pub yearindex_to_yearindex: EagerVec<YearIndex, YearIndex>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
@@ -286,247 +281,9 @@ impl Vecs {
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let dateindex_to_first_height = EagerVec::forced_import(
|
||||
path,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let dateindex_to_dateindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
dateindex_to_first_height.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let dateindex_to_date = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"date",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
dateindex_to_dateindex.boxed_clone(),
|
||||
|index, _| Some(Date::from(index)),
|
||||
)?;
|
||||
|
||||
let height_to_date =
|
||||
EagerVec::forced_import(path, "date", version + VERSION + Version::ZERO, format)?;
|
||||
|
||||
let height_to_height = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"height",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
indexer.vecs().height_to_weight.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let height_to_difficultyepoch = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"difficultyepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
height_to_height.boxed_clone(),
|
||||
|index, _| Some(DifficultyEpoch::from(index)),
|
||||
)?;
|
||||
|
||||
let difficultyepoch_to_first_height = EagerVec::forced_import(
|
||||
path,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let difficultyepoch_to_difficultyepoch = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"difficultyepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
difficultyepoch_to_first_height.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let height_to_halvingepoch = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"halvingepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
height_to_height.boxed_clone(),
|
||||
|index, _| Some(HalvingEpoch::from(index)),
|
||||
)?;
|
||||
|
||||
let halvingepoch_to_first_height = EagerVec::forced_import(
|
||||
path,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let halvingepoch_to_halvingepoch = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"halvingepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
halvingepoch_to_first_height.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let dateindex_to_weekindex =
|
||||
EagerVec::forced_import(path, "weekindex", version + VERSION + Version::ZERO, format)?;
|
||||
|
||||
let weekindex_to_first_dateindex = EagerVec::forced_import(
|
||||
path,
|
||||
"first_dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let weekindex_to_weekindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"weekindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
weekindex_to_first_dateindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let dateindex_to_monthindex = EagerVec::forced_import(
|
||||
path,
|
||||
"monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let monthindex_to_first_dateindex = EagerVec::forced_import(
|
||||
path,
|
||||
"first_dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let monthindex_to_monthindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
monthindex_to_first_dateindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let monthindex_to_quarterindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"quarterindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
monthindex_to_monthindex.boxed_clone(),
|
||||
|index, _| Some(QuarterIndex::from(index)),
|
||||
)?;
|
||||
|
||||
let quarterindex_to_first_monthindex = EagerVec::forced_import(
|
||||
path,
|
||||
"first_monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let quarterindex_to_quarterindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"quarterindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
quarterindex_to_first_monthindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let monthindex_to_yearindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
monthindex_to_monthindex.boxed_clone(),
|
||||
|index, _| Some(YearIndex::from(index)),
|
||||
)?;
|
||||
|
||||
let yearindex_to_first_monthindex = EagerVec::forced_import(
|
||||
path,
|
||||
"first_monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let yearindex_to_yearindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
yearindex_to_first_monthindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
let yearindex_to_decadeindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"decadeindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
yearindex_to_yearindex.boxed_clone(),
|
||||
|index, _| Some(DecadeIndex::from(index)),
|
||||
)?;
|
||||
|
||||
let decadeindex_to_first_yearindex = EagerVec::forced_import(
|
||||
path,
|
||||
"first_yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?;
|
||||
|
||||
let decadeindex_to_decadeindex = ComputedVec::forced_import_or_init_from_1(
|
||||
computation,
|
||||
path,
|
||||
"decadeindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
decadeindex_to_first_yearindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
)?;
|
||||
|
||||
Ok(Self {
|
||||
dateindex_to_date,
|
||||
dateindex_to_dateindex,
|
||||
dateindex_to_first_height,
|
||||
dateindex_to_monthindex,
|
||||
dateindex_to_weekindex,
|
||||
decadeindex_to_decadeindex,
|
||||
decadeindex_to_first_yearindex,
|
||||
difficultyepoch_to_difficultyepoch,
|
||||
difficultyepoch_to_first_height,
|
||||
emptyoutputindex_to_emptyoutputindex,
|
||||
halvingepoch_to_first_height,
|
||||
halvingepoch_to_halvingepoch,
|
||||
height_to_date,
|
||||
height_to_difficultyepoch,
|
||||
height_to_halvingepoch,
|
||||
height_to_height,
|
||||
inputindex_to_inputindex,
|
||||
monthindex_to_first_dateindex,
|
||||
monthindex_to_monthindex,
|
||||
monthindex_to_quarterindex,
|
||||
monthindex_to_yearindex,
|
||||
opreturnindex_to_opreturnindex,
|
||||
outputindex_to_outputindex,
|
||||
p2aindex_to_p2aindex,
|
||||
@@ -538,17 +295,167 @@ impl Vecs {
|
||||
p2trindex_to_p2trindex,
|
||||
p2wpkhindex_to_p2wpkhindex,
|
||||
p2wshindex_to_p2wshindex,
|
||||
quarterindex_to_first_monthindex,
|
||||
quarterindex_to_quarterindex,
|
||||
txindex_to_txindex,
|
||||
txindex_to_input_count,
|
||||
txindex_to_output_count,
|
||||
txindex_to_txindex,
|
||||
unknownoutputindex_to_unknownoutputindex,
|
||||
weekindex_to_first_dateindex,
|
||||
weekindex_to_weekindex,
|
||||
yearindex_to_decadeindex,
|
||||
yearindex_to_first_monthindex,
|
||||
yearindex_to_yearindex,
|
||||
|
||||
dateindex_to_date: EagerVec::forced_import(
|
||||
path,
|
||||
"date",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
dateindex_to_dateindex: EagerVec::forced_import(
|
||||
path,
|
||||
"dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
dateindex_to_first_height: EagerVec::forced_import(
|
||||
path,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
dateindex_to_monthindex: EagerVec::forced_import(
|
||||
path,
|
||||
"monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
dateindex_to_weekindex: EagerVec::forced_import(
|
||||
path,
|
||||
"weekindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
decadeindex_to_decadeindex: EagerVec::forced_import(
|
||||
path,
|
||||
"decadeindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
decadeindex_to_first_yearindex: EagerVec::forced_import(
|
||||
path,
|
||||
"first_yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
difficultyepoch_to_difficultyepoch: EagerVec::forced_import(
|
||||
path,
|
||||
"difficultyepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
difficultyepoch_to_first_height: EagerVec::forced_import(
|
||||
path,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
halvingepoch_to_first_height: EagerVec::forced_import(
|
||||
path,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
halvingepoch_to_halvingepoch: EagerVec::forced_import(
|
||||
path,
|
||||
"halvingepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
height_to_date: EagerVec::forced_import(
|
||||
path,
|
||||
"date",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
height_to_difficultyepoch: EagerVec::forced_import(
|
||||
path,
|
||||
"difficultyepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
height_to_halvingepoch: EagerVec::forced_import(
|
||||
path,
|
||||
"halvingepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
height_to_height: EagerVec::forced_import(
|
||||
path,
|
||||
"height",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
monthindex_to_first_dateindex: EagerVec::forced_import(
|
||||
path,
|
||||
"first_dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
monthindex_to_monthindex: EagerVec::forced_import(
|
||||
path,
|
||||
"monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
monthindex_to_quarterindex: EagerVec::forced_import(
|
||||
path,
|
||||
"quarterindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
monthindex_to_yearindex: EagerVec::forced_import(
|
||||
path,
|
||||
"yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
quarterindex_to_first_monthindex: EagerVec::forced_import(
|
||||
path,
|
||||
"first_monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
weekindex_to_first_dateindex: EagerVec::forced_import(
|
||||
path,
|
||||
"first_dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
yearindex_to_first_monthindex: EagerVec::forced_import(
|
||||
path,
|
||||
"first_monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
quarterindex_to_quarterindex: EagerVec::forced_import(
|
||||
path,
|
||||
"quarterindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
weekindex_to_weekindex: EagerVec::forced_import(
|
||||
path,
|
||||
"weekindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
yearindex_to_decadeindex: EagerVec::forced_import(
|
||||
path,
|
||||
"decadeindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
yearindex_to_yearindex: EagerVec::forced_import(
|
||||
path,
|
||||
"yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)?,
|
||||
height_to_date_fixed: EagerVec::forced_import(
|
||||
path,
|
||||
"date_fixed",
|
||||
@@ -654,6 +561,12 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.txindex_to_input_count.compute_if_necessary(
|
||||
starting_indexes.txindex,
|
||||
&indexer_vecs.txindex_to_txid,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.outputindex_to_txindex.compute_inverse_less_to_more(
|
||||
starting_indexes.txindex,
|
||||
&indexer_vecs.txindex_to_first_outputindex,
|
||||
@@ -773,7 +686,7 @@ impl Vecs {
|
||||
// Height
|
||||
// ---
|
||||
|
||||
self.height_to_height.compute_if_necessary(
|
||||
self.height_to_height.compute_from_index(
|
||||
starting_indexes.height,
|
||||
&indexer_vecs.height_to_weight,
|
||||
exit,
|
||||
@@ -851,13 +764,13 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_dateindex.compute_if_necessary(
|
||||
self.dateindex_to_dateindex.compute_from_index(
|
||||
starting_dateindex,
|
||||
&self.dateindex_to_first_height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_date.compute_if_necessary(
|
||||
self.dateindex_to_date.compute_from_index(
|
||||
starting_dateindex,
|
||||
&self.dateindex_to_first_height,
|
||||
exit,
|
||||
@@ -890,7 +803,7 @@ impl Vecs {
|
||||
self.weekindex_to_first_dateindex
|
||||
.compute_inverse_more_to_less(starting_dateindex, &self.dateindex_to_weekindex, exit)?;
|
||||
|
||||
self.weekindex_to_weekindex.compute_if_necessary(
|
||||
self.weekindex_to_weekindex.compute_from_index(
|
||||
starting_weekindex,
|
||||
&self.weekindex_to_first_dateindex,
|
||||
exit,
|
||||
@@ -914,7 +827,7 @@ impl Vecs {
|
||||
.get_inner(decremented_starting_height)
|
||||
.unwrap_or_default();
|
||||
|
||||
self.height_to_difficultyepoch.compute_if_necessary(
|
||||
self.height_to_difficultyepoch.compute_from_index(
|
||||
starting_indexes.height,
|
||||
&indexer_vecs.height_to_weight,
|
||||
exit,
|
||||
@@ -927,12 +840,11 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.difficultyepoch_to_difficultyepoch
|
||||
.compute_if_necessary(
|
||||
starting_difficultyepoch,
|
||||
&self.difficultyepoch_to_first_height,
|
||||
exit,
|
||||
)?;
|
||||
self.difficultyepoch_to_difficultyepoch.compute_from_index(
|
||||
starting_difficultyepoch,
|
||||
&self.difficultyepoch_to_first_height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.difficultyepoch_to_height_count
|
||||
.compute_count_from_indexes(
|
||||
@@ -966,7 +878,7 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.monthindex_to_monthindex.compute_if_necessary(
|
||||
self.monthindex_to_monthindex.compute_from_index(
|
||||
starting_monthindex,
|
||||
&self.monthindex_to_first_dateindex,
|
||||
exit,
|
||||
@@ -990,7 +902,7 @@ impl Vecs {
|
||||
.get_inner(starting_monthindex)
|
||||
.unwrap_or_default();
|
||||
|
||||
self.monthindex_to_quarterindex.compute_if_necessary(
|
||||
self.monthindex_to_quarterindex.compute_from_index(
|
||||
starting_monthindex,
|
||||
&self.monthindex_to_first_dateindex,
|
||||
exit,
|
||||
@@ -1005,7 +917,7 @@ impl Vecs {
|
||||
|
||||
// let quarter_count = self.quarterindex_to_first_monthindex.len();
|
||||
|
||||
self.quarterindex_to_quarterindex.compute_if_necessary(
|
||||
self.quarterindex_to_quarterindex.compute_from_index(
|
||||
starting_quarterindex,
|
||||
&self.quarterindex_to_first_monthindex,
|
||||
exit,
|
||||
@@ -1029,7 +941,7 @@ impl Vecs {
|
||||
.get_inner(starting_monthindex)
|
||||
.unwrap_or_default();
|
||||
|
||||
self.monthindex_to_yearindex.compute_if_necessary(
|
||||
self.monthindex_to_yearindex.compute_from_index(
|
||||
starting_monthindex,
|
||||
&self.monthindex_to_first_dateindex,
|
||||
exit,
|
||||
@@ -1042,7 +954,7 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.yearindex_to_yearindex.compute_if_necessary(
|
||||
self.yearindex_to_yearindex.compute_from_index(
|
||||
starting_yearindex,
|
||||
&self.yearindex_to_first_monthindex,
|
||||
exit,
|
||||
@@ -1065,7 +977,7 @@ impl Vecs {
|
||||
.get_inner(decremented_starting_height)
|
||||
.unwrap_or_default();
|
||||
|
||||
self.height_to_halvingepoch.compute_if_necessary(
|
||||
self.height_to_halvingepoch.compute_from_index(
|
||||
starting_indexes.height,
|
||||
&indexer_vecs.height_to_weight,
|
||||
exit,
|
||||
@@ -1078,7 +990,7 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.halvingepoch_to_halvingepoch.compute_if_necessary(
|
||||
self.halvingepoch_to_halvingepoch.compute_from_index(
|
||||
starting_halvingepoch,
|
||||
&self.halvingepoch_to_first_height,
|
||||
exit,
|
||||
@@ -1094,7 +1006,7 @@ impl Vecs {
|
||||
.get_inner(starting_yearindex)
|
||||
.unwrap_or_default();
|
||||
|
||||
self.yearindex_to_decadeindex.compute_if_necessary(
|
||||
self.yearindex_to_decadeindex.compute_from_index(
|
||||
starting_yearindex,
|
||||
&self.yearindex_to_first_monthindex,
|
||||
exit,
|
||||
@@ -1107,7 +1019,7 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.decadeindex_to_decadeindex.compute_if_necessary(
|
||||
self.decadeindex_to_decadeindex.compute_from_index(
|
||||
starting_decadeindex,
|
||||
&self.decadeindex_to_first_yearindex,
|
||||
exit,
|
||||
|
||||
@@ -585,7 +585,7 @@ impl Vecs {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&suffix("negative_unrealized_loss"),
|
||||
false,
|
||||
true,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -605,7 +605,7 @@ impl Vecs {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&suffix("net_unrealized_profit_and_loss"),
|
||||
false,
|
||||
true,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
@@ -628,7 +628,7 @@ impl Vecs {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&suffix("net_unrealized_profit_and_loss_relative_to_market_cap"),
|
||||
false,
|
||||
true,
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
|
||||
@@ -805,6 +805,18 @@ impl Vecs {
|
||||
// },
|
||||
// )?;
|
||||
|
||||
self.txindex_to_fee.compute_if_necessary(
|
||||
starting_indexes.txindex,
|
||||
&indexer.vecs().txindex_to_txid,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.txindex_to_feerate.compute_if_necessary(
|
||||
starting_indexes.txindex,
|
||||
&indexer.vecs().txindex_to_txid,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.indexes_to_fee.compute_rest(
|
||||
indexer,
|
||||
indexes,
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::{
|
||||
fmt::Debug,
|
||||
ops::{Add, Div, Mul},
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
@@ -29,7 +30,7 @@ const DCA_AMOUNT: Dollars = Dollars::mint(100.0);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EagerVec<I, T> {
|
||||
computed_version: Option<Version>,
|
||||
computed_version: Arc<ArcSwap<Option<Version>>>,
|
||||
inner: StoredVec<I, T>,
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ where
|
||||
let inner = StoredVec::forced_import(path, value_name, version, format)?;
|
||||
|
||||
Ok(Self {
|
||||
computed_version: None,
|
||||
computed_version: Arc::new(ArcSwap::from_pointee(None)),
|
||||
inner,
|
||||
})
|
||||
}
|
||||
@@ -132,7 +133,7 @@ where
|
||||
self.inner.reset()?;
|
||||
}
|
||||
version.write(path.as_ref())?;
|
||||
self.computed_version = Some(version);
|
||||
self.computed_version.store(Arc::new(Some(version)));
|
||||
|
||||
if self.is_empty() {
|
||||
info!("Computing {}...", self.name())
|
||||
@@ -179,6 +180,25 @@ where
|
||||
self.compute_to(max_from, other.len(), other.version(), t, exit)
|
||||
}
|
||||
|
||||
pub fn compute_from_index<T2>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
other: &impl AnyIterableVec<I, T2>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
T: From<I>,
|
||||
T2: StoredType,
|
||||
{
|
||||
self.compute_to(
|
||||
max_from,
|
||||
other.len(),
|
||||
other.version(),
|
||||
|i| (i, T::from(i)),
|
||||
exit,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn compute_transform<A, B, F>(
|
||||
&mut self,
|
||||
max_from: A,
|
||||
@@ -579,7 +599,10 @@ where
|
||||
<T2 as TryInto<T>>::Error: error::Error + 'static,
|
||||
{
|
||||
self.validate_computed_version_or_reset_file(
|
||||
Version::ZERO + self.inner.version() + first_indexes.version(),
|
||||
Version::ZERO
|
||||
+ self.inner.version()
|
||||
+ first_indexes.version()
|
||||
+ other_to_else.version(),
|
||||
)?;
|
||||
|
||||
let mut other_iter = first_indexes.iter();
|
||||
@@ -1193,7 +1216,11 @@ impl EagerVec<TxIndex, Dollars> {
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.validate_computed_version_or_reset_file(
|
||||
Version::ZERO + self.inner.version() + bitcoin.version(),
|
||||
Version::ZERO
|
||||
+ self.inner.version()
|
||||
+ bitcoin.version()
|
||||
+ i_to_height.version()
|
||||
+ price.version(),
|
||||
)?;
|
||||
|
||||
let mut i_to_height_iter = i_to_height.iter();
|
||||
@@ -1231,6 +1258,7 @@ where
|
||||
#[inline]
|
||||
fn version(&self) -> Version {
|
||||
self.computed_version
|
||||
.load()
|
||||
.or_else(|| {
|
||||
dbg!(self.path());
|
||||
None
|
||||
|
||||
@@ -809,6 +809,8 @@
|
||||
}
|
||||
|
||||
#share-div {
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: var(--line-height-sm);
|
||||
padding: 1.5rem;
|
||||
backdrop-filter: blur(12px);
|
||||
position: absolute;
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
* "WU" |
|
||||
* "Bool" |
|
||||
* "Days" |
|
||||
* "%mcap" |
|
||||
* "Years" |
|
||||
* "Locktime" |
|
||||
* "sat/vB" |
|
||||
@@ -738,7 +739,9 @@ function createUtils() {
|
||||
id.endsWith("price") ||
|
||||
id.endsWith("value-created") ||
|
||||
id.endsWith("value-destroyed") ||
|
||||
(id.includes("realized") && !id.includes("ratio")) ||
|
||||
(id.includes("realized") &&
|
||||
!id.includes("ratio") &&
|
||||
!id.includes("relative-to")) ||
|
||||
(id.endsWith("sma") && !id.includes("ratio")) ||
|
||||
id.endsWith("ath"))
|
||||
) {
|
||||
@@ -871,6 +874,10 @@ function createUtils() {
|
||||
if (unit) throw Error(`Unit "${unit}" already assigned "${id}"`);
|
||||
unit = "Height";
|
||||
}
|
||||
if ((!unit || thoroughUnitCheck) && id.endsWith("relative-to-market-cap")) {
|
||||
if (unit) throw Error(`Unit "${unit}" already assigned "${id}"`);
|
||||
unit = "%mcap";
|
||||
}
|
||||
if ((!unit || thoroughUnitCheck) && id.endsWith("epoch")) {
|
||||
if (unit) throw Error(`Unit "${unit}" already assigned "${id}"`);
|
||||
unit = "Epoch";
|
||||
|
||||
@@ -568,8 +568,8 @@ function createPartialOptions(colors) {
|
||||
const fromSize = /** @type {const} */ ([
|
||||
{
|
||||
key: "from-1-000sats",
|
||||
name: "1_000sats",
|
||||
title: "From 1,000 sats",
|
||||
name: "1K sats",
|
||||
title: "From 1K sats",
|
||||
color: colors.cyan,
|
||||
},
|
||||
{
|
||||
@@ -595,14 +595,14 @@ function createPartialOptions(colors) {
|
||||
const upToSize = /** @type {const} */ ([
|
||||
{
|
||||
key: "up-to-1-000sats",
|
||||
name: "1_000sats",
|
||||
title: "Up to 1,000 sats",
|
||||
name: "1K sats",
|
||||
title: "Up to 1K sats",
|
||||
color: colors.yellow,
|
||||
},
|
||||
{
|
||||
key: "up-to-10-000sats",
|
||||
name: "10_000sats",
|
||||
title: "Up to 10,000 sats",
|
||||
name: "10K sats",
|
||||
title: "Up to 10K sats",
|
||||
color: colors.green,
|
||||
},
|
||||
{
|
||||
@@ -628,92 +628,92 @@ function createPartialOptions(colors) {
|
||||
const sizeRanges = /** @type {const} */ ([
|
||||
{
|
||||
key: "0sats",
|
||||
name: "0sats",
|
||||
name: "0 sats",
|
||||
title: "0 sats",
|
||||
color: colors.red,
|
||||
},
|
||||
{
|
||||
key: "from-1sat-to-10sats",
|
||||
name: "1sat..10sats",
|
||||
name: "1 sat..10 sats",
|
||||
title: "From 1 sat to 10 sats",
|
||||
color: colors.orange,
|
||||
},
|
||||
{
|
||||
key: "from-10sats-to-100sats",
|
||||
name: "10sat..100sats",
|
||||
name: "10 sats..100 sats",
|
||||
title: "From 10 sats to 100 sats",
|
||||
color: colors.yellow,
|
||||
},
|
||||
{
|
||||
key: "from-100sats-to-1-000sats",
|
||||
name: "100sat..1_000sats",
|
||||
title: "From 100 sats to 1,000 sats",
|
||||
name: "100 sats..1K sats",
|
||||
title: "From 100 sats to 1K sats",
|
||||
color: colors.lime,
|
||||
},
|
||||
{
|
||||
key: "from-1-000sats-to-10-000sats",
|
||||
name: "1_000sat..10_000sats",
|
||||
title: "From 1,000 sats to 10,000 sats",
|
||||
name: "1K sats..10K sats",
|
||||
title: "From 1K sats to 10K sats",
|
||||
color: colors.green,
|
||||
},
|
||||
{
|
||||
key: "from-10-000sats-to-100-000sats",
|
||||
name: "10_000sat..100_000sats",
|
||||
title: "From 10,000 sats to 100,000 sats",
|
||||
name: "10K sats..100K sats",
|
||||
title: "From 10K sats to 100K sats",
|
||||
color: colors.cyan,
|
||||
},
|
||||
{
|
||||
key: "from-100-000sats-to-1-000-000sats",
|
||||
name: "100_000sat..1_000_000sats",
|
||||
title: "From 100,000 sats to 1,000,000 sats",
|
||||
name: "100K sats .. 1M sats",
|
||||
title: "From 100K sats to 1M sats",
|
||||
color: colors.blue,
|
||||
},
|
||||
{
|
||||
key: "from-1-000-000sats-to-10-000-000sats",
|
||||
name: "1_000_000sat..10_000_000sats",
|
||||
title: "From 1,000,000 sats to 10,000,000 sats",
|
||||
name: "1M sats..10M sats",
|
||||
title: "From 1M sats to 10M sats",
|
||||
color: colors.indigo,
|
||||
},
|
||||
{
|
||||
key: "from-10-000-000sats-to-1btc",
|
||||
name: "10_000_000sat..1btc",
|
||||
title: "From 10,000,000 sats to 1 BTC",
|
||||
name: "10M sats..1 btc",
|
||||
title: "From 10M sats to 1 BTC",
|
||||
color: colors.purple,
|
||||
},
|
||||
{
|
||||
key: "from-1btc-to-10btc",
|
||||
name: "1btc..10btc",
|
||||
name: "1 btc..10 btc",
|
||||
title: "From 1 BTC to 10 BTC",
|
||||
color: colors.violet,
|
||||
},
|
||||
{
|
||||
key: "from-10btc-to-100btc",
|
||||
name: "10btc..100btc",
|
||||
name: "10 btc..100 btc",
|
||||
title: "From 10 BTC to 100 BTC",
|
||||
color: colors.fuchsia,
|
||||
},
|
||||
{
|
||||
key: "from-100btc-to-1-000btc",
|
||||
name: "100btc..1_000btc",
|
||||
title: "From 100 BTC to 1,000 BTC",
|
||||
name: "100 btc..1K btc",
|
||||
title: "From 100 BTC to 1K BTC",
|
||||
color: colors.pink,
|
||||
},
|
||||
{
|
||||
key: "from-1-000btc-to-10-000btc",
|
||||
name: "1_000btc..10_000btc",
|
||||
title: "From 1,000 BTC to 10,000 BTC",
|
||||
name: "1K btc..10K btc",
|
||||
title: "From 1K BTC to 10K BTC",
|
||||
color: colors.red,
|
||||
},
|
||||
{
|
||||
key: "from-10-000btc-to-100-000btc",
|
||||
name: "10_000btc..100_000btc",
|
||||
title: "From 10,000 BTC to 100,000 BTC",
|
||||
name: "10K btc..100K btc",
|
||||
title: "From 10K BTC to 100K BTC",
|
||||
color: colors.orange,
|
||||
},
|
||||
{
|
||||
key: "from-100-000btc",
|
||||
name: "100_000btc+",
|
||||
title: "From 100,000 BTC",
|
||||
name: "100K btc+",
|
||||
title: "From 100K BTC",
|
||||
color: colors.yellow,
|
||||
},
|
||||
]);
|
||||
@@ -1216,8 +1216,26 @@ function createPartialOptions(colors) {
|
||||
name: useGroupName ? name : "Supply",
|
||||
color: "list" in args ? color : colors.default,
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: `${key}supply-in-btc`,
|
||||
name: useGroupName ? name : "Supply",
|
||||
color: "list" in args ? color : colors.default,
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: `${key}supply-in-usd`,
|
||||
name: useGroupName ? name : "Supply",
|
||||
color: "list" in args ? color : colors.default,
|
||||
}),
|
||||
...(!("list" in args)
|
||||
? [
|
||||
createBaseSeries({
|
||||
key: `${key}halved-supply`,
|
||||
name: useGroupName ? name : "Halved",
|
||||
color: "list" in args ? color : colors.gray,
|
||||
options: {
|
||||
lineStyle: 4,
|
||||
},
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: `${key}supply-in-profit`,
|
||||
name: useGroupName ? name : "In Profit",
|
||||
@@ -1233,17 +1251,54 @@ function createPartialOptions(colors) {
|
||||
name: useGroupName ? name : "Even",
|
||||
color: colors.yellow,
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: `${key}halved-supply-in-btc`,
|
||||
name: useGroupName ? name : "Halved",
|
||||
color: "list" in args ? color : colors.gray,
|
||||
options: {
|
||||
lineStyle: 4,
|
||||
},
|
||||
}),
|
||||
// createBaseSeries({
|
||||
// key: `${key}supply-in-profit-in-btc`,
|
||||
// name: useGroupName ? name : "In Profit",
|
||||
// color: colors.green,
|
||||
// }),
|
||||
// createBaseSeries({
|
||||
// key: `${key}supply-in-loss-in-btc`,
|
||||
// name: useGroupName ? name : "In Loss",
|
||||
// color: colors.red,
|
||||
// }),
|
||||
// createBaseSeries({
|
||||
// key: `${key}supply-even-in-btc`,
|
||||
// name: useGroupName ? name : "Even",
|
||||
// color: colors.yellow,
|
||||
// }),
|
||||
createBaseSeries({
|
||||
key: `${key}halved-supply-in-usd`,
|
||||
name: useGroupName ? name : "Halved",
|
||||
color: "list" in args ? color : colors.gray,
|
||||
options: {
|
||||
lineStyle: 4,
|
||||
},
|
||||
}),
|
||||
// createBaseSeries({
|
||||
// key: `${key}supply-in-profit-in-usd`,
|
||||
// name: useGroupName ? name : "In Profit",
|
||||
// color: colors.green,
|
||||
// }),
|
||||
// createBaseSeries({
|
||||
// key: `${key}supply-in-loss-in-usd`,
|
||||
// name: useGroupName ? name : "In Loss",
|
||||
// color: colors.red,
|
||||
// }),
|
||||
// createBaseSeries({
|
||||
// key: `${key}supply-even-in-usd`,
|
||||
// name: useGroupName ? name : "Even",
|
||||
// color: colors.yellow,
|
||||
// }),
|
||||
]
|
||||
: []),
|
||||
createBaseSeries({
|
||||
key: `${key}supply-in-btc`,
|
||||
name: useGroupName ? name : "Supply",
|
||||
color,
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: `${key}supply-in-usd`,
|
||||
name: useGroupName ? name : "Supply",
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
},
|
||||
@@ -1312,34 +1367,6 @@ function createPartialOptions(colors) {
|
||||
legend: "realized",
|
||||
color: args.color,
|
||||
}),
|
||||
{
|
||||
name: "profit",
|
||||
title: `${args.title} Realized Profit`,
|
||||
bottom: list.flatMap(({ color, name, key: _key }) => {
|
||||
const key = fixKey(_key);
|
||||
return /** @type {const} */ ([
|
||||
createBaseSeries({
|
||||
key: `${key}realized-profit`,
|
||||
name: useGroupName ? name : "Profit",
|
||||
color: useGroupName ? color : colors.green,
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "loss",
|
||||
title: `${args.title} Realized Loss`,
|
||||
bottom: list.flatMap(({ color, name, key: _key }) => {
|
||||
const key = fixKey(_key);
|
||||
return /** @type {const} */ ([
|
||||
createBaseSeries({
|
||||
key: `${key}realized-loss`,
|
||||
name: useGroupName ? name : "Loss",
|
||||
color: useGroupName ? color : colors.red,
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
},
|
||||
...(!("list" in args)
|
||||
? [
|
||||
{
|
||||
@@ -1365,9 +1392,38 @@ function createPartialOptions(colors) {
|
||||
],
|
||||
},
|
||||
]
|
||||
: []),
|
||||
: [
|
||||
{
|
||||
name: "profit",
|
||||
title: `${args.title} Realized Profit`,
|
||||
bottom: list.flatMap(({ color, name, key: _key }) => {
|
||||
const key = fixKey(_key);
|
||||
return /** @type {const} */ ([
|
||||
createBaseSeries({
|
||||
key: `${key}realized-profit`,
|
||||
name: useGroupName ? name : "Profit",
|
||||
color: useGroupName ? color : colors.green,
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "loss",
|
||||
title: `${args.title} Realized Loss`,
|
||||
bottom: list.flatMap(({ color, name, key: _key }) => {
|
||||
const key = fixKey(_key);
|
||||
return /** @type {const} */ ([
|
||||
createBaseSeries({
|
||||
key: `${key}realized-loss`,
|
||||
name: useGroupName ? name : "Loss",
|
||||
color: useGroupName ? color : colors.red,
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
},
|
||||
]),
|
||||
{
|
||||
name: "Net Profit And Loss",
|
||||
name: "Net pnl",
|
||||
title: `${args.title} Net Realized Profit And Loss`,
|
||||
bottom: list.flatMap(
|
||||
({ color, name, key }) =>
|
||||
@@ -1385,7 +1441,7 @@ function createPartialOptions(colors) {
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "Spent Output Profit Ratio",
|
||||
name: "sopr",
|
||||
title: `${args.title} Spent Output Profit Ratio`,
|
||||
bottom: list.flatMap(({ color, name, key }) => [
|
||||
/** @satisfies {FetchedBaselineSeriesBlueprint} */ ({
|
||||
@@ -1428,33 +1484,96 @@ function createPartialOptions(colors) {
|
||||
{
|
||||
name: "Unrealized",
|
||||
tree: [
|
||||
...(!("list" in args)
|
||||
? [
|
||||
{
|
||||
name: "profit and loss",
|
||||
title: `${args.title} Unrealized Profit And Loss`,
|
||||
bottom: [
|
||||
// createBaseSeries({
|
||||
// key: `0`,
|
||||
// name: "Base",
|
||||
// color: colors.gray,
|
||||
// options: {
|
||||
// lineStyle: 4,
|
||||
// },
|
||||
// }),
|
||||
createBaseSeries({
|
||||
key: `${fixKey(args.key)}unrealized-profit`,
|
||||
name: "Profit",
|
||||
color: colors.green,
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: `${fixKey(args.key)}unrealized-loss`,
|
||||
name: "Loss",
|
||||
color: colors.red,
|
||||
defaultActive: false,
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: `${fixKey(args.key)}negative-unrealized-loss`,
|
||||
name: "Negative Loss",
|
||||
color: colors.red,
|
||||
}),
|
||||
],
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
name: "profit",
|
||||
title: `${args.title} Unrealized Profit`,
|
||||
bottom: list.flatMap(({ color, name, key: _key }) => {
|
||||
const key = fixKey(_key);
|
||||
return /** @type {const} */ ([
|
||||
createBaseSeries({
|
||||
key: `${key}unrealized-profit`,
|
||||
name: useGroupName ? name : "Profit",
|
||||
color: useGroupName ? color : colors.green,
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "loss",
|
||||
title: `${args.title} Unrealized Loss`,
|
||||
bottom: list.flatMap(({ color, name, key: _key }) => {
|
||||
const key = fixKey(_key);
|
||||
return /** @type {const} */ ([
|
||||
createBaseSeries({
|
||||
key: `${key}unrealized-loss`,
|
||||
name: useGroupName ? name : "Loss",
|
||||
color: useGroupName ? color : colors.red,
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
},
|
||||
]),
|
||||
{
|
||||
name: "profit",
|
||||
title: `${args.title} Unrealized Profit`,
|
||||
bottom: list.flatMap(({ color, name, key: _key }) => {
|
||||
const key = fixKey(_key);
|
||||
return /** @type {const} */ ([
|
||||
createBaseSeries({
|
||||
key: `${key}unrealized-profit`,
|
||||
name: useGroupName ? name : "Profit",
|
||||
color: useGroupName ? color : colors.green,
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "loss",
|
||||
title: `${args.title} Unrealized Loss`,
|
||||
bottom: list.flatMap(({ color, name, key: _key }) => {
|
||||
const key = fixKey(_key);
|
||||
return /** @type {const} */ ([
|
||||
createBaseSeries({
|
||||
key: `${key}unrealized-loss`,
|
||||
name: useGroupName ? name : "Loss",
|
||||
color: useGroupName ? color : colors.red,
|
||||
}),
|
||||
]);
|
||||
}),
|
||||
name: "Net pnl",
|
||||
title: `${args.title} Net Unrealized Profit And Loss`,
|
||||
bottom: list.flatMap(({ color, name, key }) => [
|
||||
/** @satisfies {FetchedBaselineSeriesBlueprint} */ ({
|
||||
type: "Baseline",
|
||||
key: `${fixKey(key)}net-unrealized-profit-and-loss`,
|
||||
title: useGroupName ? name : "Net",
|
||||
color: useGroupName ? color : undefined,
|
||||
options: {
|
||||
createPriceLine: {
|
||||
value: 0,
|
||||
},
|
||||
},
|
||||
}),
|
||||
/** @satisfies {FetchedBaselineSeriesBlueprint} */ ({
|
||||
type: "Baseline",
|
||||
key: `${fixKey(key)}net-unrealized-profit-and-loss-relative-to-market-cap`,
|
||||
title: useGroupName ? name : "Net",
|
||||
color: useGroupName ? color : undefined,
|
||||
options: {
|
||||
createPriceLine: {
|
||||
value: 0,
|
||||
},
|
||||
},
|
||||
}),
|
||||
]),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -2553,6 +2672,20 @@ function createPartialOptions(colors) {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Services",
|
||||
tree: [
|
||||
{
|
||||
name: "Self-host",
|
||||
url: () => "https://crates.io/crates/brk_cli",
|
||||
},
|
||||
{
|
||||
name: "Hosting as a service",
|
||||
url: () =>
|
||||
"https://github.com/bitcoinresearchkit/brk?tab=readme-ov-file#hosting-as-a-service",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Developers",
|
||||
tree: [
|
||||
@@ -2575,27 +2708,19 @@ function createPartialOptions(colors) {
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Donations",
|
||||
name: "Donate",
|
||||
tree: [
|
||||
{
|
||||
name: "Bitcoin QR Code",
|
||||
name: "Bitcoin",
|
||||
qrcode: true,
|
||||
url: () => "bitcoin:bc1q098zsm89m7kgyze338vfejhpdt92ua9p3peuve",
|
||||
},
|
||||
{
|
||||
name: "Lightning QR Code",
|
||||
name: "Lightning",
|
||||
qrcode: true,
|
||||
url: () =>
|
||||
"lightning:lnurl1dp68gurn8ghj7ampd3kx2ar0veekzar0wd5xjtnrdakj7tnhv4kxctttdehhwm30d3h82unvwqhkxmmww3jkuar8d35kgetj8yuq363hv4",
|
||||
},
|
||||
{
|
||||
name: "Geyser",
|
||||
url: () => "https://geyser.fund/project/brk",
|
||||
},
|
||||
{
|
||||
name: "OpenSats",
|
||||
url: () => "https://opensats.org/",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user