Duplicate and misplaced logic in roles crates #997
Labels
job-declarator-client
job-declarator-server
refactor
Implies refactoring code
sv2 pool
sv2 proxy
translation proxy
SV1>SV2 translation proxy issues
Background
When reviewing @plebhash #813, I found a lot of general and/or duplicate logic within each role's crate.
common
crate (which is being severely under utilized). This issue identifies logic within theroles
crates that should be moved/aggregated.main
tolib
#992 points out that DC initialization is happening inside main.rs rather than lib.rs which makes it not very modular.Problem
This logic is misplaced (does not make sense to belong to a specific role), and there is a lot of duplicate logic that can lead to bugs.
For example:
fn duration_from_toml
is repeated injd-server::lib::mod
andjd-client::lib::proxy_config
.CoinbaseOutput
is repeated injd-server::lib::mod
,jd-client::lib::proxy_config
, andpool::lib::mining_pool::mod
. This is only needed because theroles_logic_sv2::CoinbaseOutput
does not deriveserde::Deserialize
which is needed when using thetoml
crate to read and parse the config tomls.fn get_coinbase_output
is repeated injd-server::lib::mod
,jd-client::lib::proxy_config
, andpool::lib::mining_pool::mod
. It is used to read and parse thecoinbase_outputs
from the role's config tomls.Args
logic intranslator::args
andjd-client::args
Solution
Identify all the duplicate and common logic within the
roles
crates and begin moving them into thecommon
crate.Proper Handling of
CoinbaseOutput
Regarding the duplicate
CoinbaseOutput
, this logic can be completely removed if a custom deserialization onConfig
is added like:In order to make the
get_coinbase_output
method working, the following implementation should be added toprotocols::v2::roles_logic_sv2::utils
:Then all duplicate
CoinbaseOutput
structs in the roles crates can be removed.The text was updated successfully, but these errors were encountered: