Allow multiple configurations in blockchains
array
This commit is contained in:
parent
d2d340158e
commit
faca485ebf
4 changed files with 21 additions and 3 deletions
|
@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Added emoji count check to profile data validator.
|
- Added emoji count check to profile data validator.
|
||||||
- Check mention and link counts when creating post.
|
- Check mention and link counts when creating post.
|
||||||
- Disable transaction monitor tasks if blockchain integration is disabled.
|
- Disable transaction monitor tasks if blockchain integration is disabled.
|
||||||
|
- Allow multiple configurations in `blockchains` array.
|
||||||
|
|
||||||
## [1.20.0] - 2023-03-07
|
## [1.20.0] - 2023-03-07
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ retention:
|
||||||
#blocked_instances: []
|
#blocked_instances: []
|
||||||
|
|
||||||
# Blockchain integrations
|
# Blockchain integrations
|
||||||
# Multiple configuration are currently not allowed.
|
# Multi-chain setups are currently not supported.
|
||||||
# Chain metadata for EVM chains can be found at https://github.com/ethereum-lists/chains
|
# Chain metadata for EVM chains can be found at https://github.com/ethereum-lists/chains
|
||||||
# Signing key for ethereum integration can be generated with `mitractl generate-ethereum-address`
|
# Signing key for ethereum integration can be generated with `mitractl generate-ethereum-address`
|
||||||
#blockchains:
|
#blockchains:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use log::{Level as LogLevel};
|
use log::{Level as LogLevel};
|
||||||
|
@ -125,8 +126,21 @@ impl Config {
|
||||||
if let Some(ref _blockchain_config) = self._blockchain {
|
if let Some(ref _blockchain_config) = self._blockchain {
|
||||||
panic!("'blockchain' setting is not supported anymore, use 'blockchains' instead");
|
panic!("'blockchain' setting is not supported anymore, use 'blockchains' instead");
|
||||||
} else {
|
} else {
|
||||||
if self.blockchains.len() > 1 {
|
let is_error = self.blockchains.iter()
|
||||||
panic!("multichain deployments are not supported");
|
.fold(HashMap::new(), |mut map, blockchain_config| {
|
||||||
|
let key = match blockchain_config {
|
||||||
|
BlockchainConfig::Ethereum(_) => 1,
|
||||||
|
BlockchainConfig::Monero(_) => 2,
|
||||||
|
};
|
||||||
|
map.entry(key)
|
||||||
|
.and_modify(|count| *count += 1)
|
||||||
|
.or_insert(1);
|
||||||
|
map
|
||||||
|
})
|
||||||
|
.into_values()
|
||||||
|
.any(|count| count > 1);
|
||||||
|
if is_error {
|
||||||
|
panic!("'blockchains' array contains more than one chain of the same kind");
|
||||||
};
|
};
|
||||||
&self.blockchains
|
&self.blockchains
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,9 @@ pub fn parse_config() -> (Config, Vec<&'static str>) {
|
||||||
};
|
};
|
||||||
check_directory_owner(&config.storage_dir);
|
check_directory_owner(&config.storage_dir);
|
||||||
config.try_instance_url().expect("invalid instance URI");
|
config.try_instance_url().expect("invalid instance URI");
|
||||||
|
if config.blockchains().len() > 1 {
|
||||||
|
warnings.push("multichain deployments are not recommended");
|
||||||
|
};
|
||||||
if let Some(ethereum_config) = config.ethereum_config() {
|
if let Some(ethereum_config) = config.ethereum_config() {
|
||||||
ethereum_config.try_ethereum_chain_id().unwrap();
|
ethereum_config.try_ethereum_chain_id().unwrap();
|
||||||
if !ethereum_config.contract_dir.exists() {
|
if !ethereum_config.contract_dir.exists() {
|
||||||
|
|
Loading…
Reference in a new issue