Skip to content

Commit

Permalink
finish server & db definitions, add chain hashes to connected chains
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiderson committed Oct 4, 2024
1 parent f6b16cc commit 9ae7cf2
Show file tree
Hide file tree
Showing 14 changed files with 598 additions and 465 deletions.
128 changes: 34 additions & 94 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ Environment variables:
```

### 🕹️📝 Examples
Start the daemon, and create (or open existing) the config at the default path in the current directory, create (or open existing) the database at the default path in the current directory, and enable the default logging.
```sh
KALATORI_SEED="impulse idea people slow agent orphan color sugar siege laugh view amused property destroy ghost" \
kalatori -r 5FuwwzpHSYp8k1Bmv9fC394vGNdwqAvPRCmqYqdv3KrXpXWi
```

Start the daemon, and create (or open existing) the config at `my_config.toml` in the current directory.
```sh
KALATORI_SEED="impulse idea people slow agent orphan color sugar siege laugh view amused property destroy ghost" \
Expand Down
31 changes: 26 additions & 5 deletions src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
//! Contains everything related to CLI arguments, environment variables, and the config.
use crate::{
chain_wip::definitions::{H256, HEX_PREFIX},
chain_wip::definitions::{Url, H256, HEX_PREFIX},
database::definitions::{AssetId, Timestamp},
error::{AccountParseError, ChainIntervalError, ConfigError},
logger,
server::definitions::new::{Decimals, SS58Prefix, SubstrateAccount},
utils::PathDisplay,
};
use clap::{Arg, ArgAction, Parser};
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use std::{
borrow::Cow,
borrow::{Borrow, Cow},
env,
ffi::{OsStr, OsString},
fmt::{Debug, Display, Formatter, Result as FmtResult},
Expand Down Expand Up @@ -320,16 +320,37 @@ impl Config {
}
}

#[derive(Deserialize, Clone, Hash, PartialEq, Eq, Serialize)]
pub struct ChainName(pub Arc<str>);

impl Borrow<str> for ChainName {
fn borrow(&self) -> &str {
&self.0
}
}

impl Display for ChainName {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
Display::fmt(&self.0, f)
}
}

impl Debug for ChainName {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
Debug::fmt(&self.0, f)
}
}

#[derive(Deserialize, Clone)]
pub struct Chain {
pub name: Arc<str>,
pub name: ChainName,
#[serde(flatten)]
pub config: ChainConfig,
}

#[derive(Deserialize, Clone)]
pub struct ChainConfig {
pub endpoints: Vec<String>,
pub endpoints: Vec<Url>,
#[serde(flatten)]
pub inner: ChainConfigInner,
}
Expand Down
6 changes: 3 additions & 3 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl ChainManager {
// start network monitors
for c in chain {
if c.config.endpoints.is_empty() {
return Err(Error::EmptyEndpoints(c.name.to_string()));
return Err(Error::EmptyEndpoints(c.name.0.to_string()));
}
let (chain_tx, chain_rx) = mpsc::channel(1024);
watch_chain.insert(c.name.clone(), chain_tx.clone());
Expand Down Expand Up @@ -100,7 +100,7 @@ impl ChainManager {
} else {
let _unused = request
.res
.send(Err(ChainError::InvalidChain(chain.to_string())));
.send(Err(ChainError::InvalidChain(chain.0.to_string())));
}
} else {
let _unused = request
Expand All @@ -116,7 +116,7 @@ impl ChainManager {
} else {
let _unused = request
.res
.send(Err(ChainError::InvalidChain(chain.to_string())));
.send(Err(ChainError::InvalidChain(chain.0.to_string())));
}
} else {
let _unused = request
Expand Down
Loading

0 comments on commit 9ae7cf2

Please sign in to comment.