mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-19 06:14:47 -07:00
global: fixes
This commit is contained in:
@@ -110,8 +110,9 @@ fn topological_sort_schemas(schemas: &TypeSchemas) -> Vec<String> {
|
||||
for (name, schema) in schemas {
|
||||
let mut type_deps = BTreeSet::new();
|
||||
collect_schema_refs(schema, &mut type_deps);
|
||||
// Only keep deps that are in our schemas
|
||||
type_deps.retain(|d| schemas.contains_key(d));
|
||||
// Only keep deps that are in our schemas, and drop self-references
|
||||
// (handled at emit time by quoting via current_type)
|
||||
type_deps.retain(|d| schemas.contains_key(d) && d != name);
|
||||
deps.insert(name.clone(), type_deps);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
fs,
|
||||
fs, io,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
@@ -10,52 +10,53 @@ use brk_server::{
|
||||
};
|
||||
use brk_types::Port;
|
||||
use owo_colors::OwoColorize;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{default_brk_path, dot_brk_path, fix_user_path};
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Config {
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
brkdir: Option<String>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
brkport: Option<Port>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
website: Option<Website>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
cdn: Option<bool>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
maxweight: Option<usize>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
maxweightlocal: Option<usize>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
cachesize: Option<usize>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
bitcoindir: Option<String>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
blocksdir: Option<String>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
rpcconnect: Option<String>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
rpcport: Option<u16>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
rpccookiefile: Option<String>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
rpcuser: Option<String>,
|
||||
|
||||
#[serde(default, deserialize_with = "default_on_error")]
|
||||
#[serde(default)]
|
||||
rpcpassword: Option<String>,
|
||||
}
|
||||
|
||||
@@ -319,10 +320,18 @@ Finally, you can run the program with '-h' for help."
|
||||
}
|
||||
|
||||
fn read(path: &Path) -> Self {
|
||||
fs::read_to_string(path).map_or_else(
|
||||
|_| Config::default(),
|
||||
|contents| toml::from_str(&contents).unwrap_or_default(),
|
||||
)
|
||||
let contents = match fs::read_to_string(path) {
|
||||
Ok(contents) => contents,
|
||||
Err(e) if e.kind() == io::ErrorKind::NotFound => return Config::default(),
|
||||
Err(e) => {
|
||||
eprintln!("Cannot read {}: {e}", path.display());
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
toml::from_str(&contents).unwrap_or_else(|e| {
|
||||
eprintln!("Invalid {}:\n{e}", path.display());
|
||||
std::process::exit(1);
|
||||
})
|
||||
}
|
||||
|
||||
pub fn rpc(&self) -> Result<Client> {
|
||||
@@ -413,14 +422,3 @@ Finally, you can run the program with '-h' for help."
|
||||
self.brkport
|
||||
}
|
||||
}
|
||||
|
||||
fn default_on_error<'de, D, T>(deserializer: D) -> Result<T, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
T: Deserialize<'de> + Default,
|
||||
{
|
||||
match T::deserialize(deserializer) {
|
||||
Ok(v) => Ok(v),
|
||||
Err(_) => Ok(T::default()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8897,7 +8897,7 @@ pub struct BrkClient {
|
||||
|
||||
impl BrkClient {
|
||||
/// Client version.
|
||||
pub const VERSION: &'static str = "v0.3.0-beta.5";
|
||||
pub const VERSION: &'static str = "v0.3.0-beta.6";
|
||||
|
||||
/// Create a new client with the given base URL.
|
||||
pub fn new(base_url: impl Into<String>) -> Self {
|
||||
|
||||
@@ -70,6 +70,7 @@ struct CostBasisCohortParam {
|
||||
}
|
||||
|
||||
#[derive(Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct CostBasisQuery {
|
||||
#[serde(default)]
|
||||
bucket: UrpdAggregation,
|
||||
|
||||
@@ -4,6 +4,7 @@ use serde::Deserialize;
|
||||
use brk_types::Txid;
|
||||
|
||||
#[derive(Debug, Default, Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AddrTxidsParam {
|
||||
/// Txid to paginate from (return transactions before this one)
|
||||
pub after_txid: Option<Txid>,
|
||||
|
||||
@@ -11,6 +11,7 @@ pub struct TimestampParam {
|
||||
|
||||
/// Optional UNIX timestamp query parameter
|
||||
#[derive(Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct OptionalTimestampParam {
|
||||
pub timestamp: Option<Timestamp>,
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ pub struct UrpdCohortParam {
|
||||
|
||||
/// Query parameters for URPD endpoints.
|
||||
#[derive(Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct UrpdQuery {
|
||||
/// Aggregation strategy. Default: raw (no aggregation). Accepts `bucket` as alias.
|
||||
#[serde(default, rename = "agg", alias = "bucket")]
|
||||
|
||||
@@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Pagination parameters for paginated API endpoints
|
||||
#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Pagination {
|
||||
/// Pagination index
|
||||
#[serde(default, alias = "p")]
|
||||
|
||||
@@ -4,6 +4,7 @@ use serde::Deserialize;
|
||||
use crate::{Limit, SeriesName};
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct SearchQuery {
|
||||
/// Search query string
|
||||
pub q: SeriesName,
|
||||
|
||||
Reference in New Issue
Block a user