plebemineira / plebpool

Other
4 stars 2 forks source link

Tower Services #11

Open plebhash opened 3 months ago

plebhash commented 3 months ago

Tower

plebpool leverages the tower crate and its ecosystem.

tower-test crate is used to assert Towers work as expected.

main.rs is responsible for waiting on these two tokio::task::JoinHandle handles:

All plebpool logic is handled asyncrhonously inside these two main tasks.

LN Service Tower

struct LnChannelManagerService { ... }
struct LnPaymentService { ... }

impl tower::Service<LnChannelManagerRequest> for LnChannelManagerService { ... }
impl tower::Service<LnPaymentRequest> for LnPaymentService { ... }

struct LnTower {
  ln_channel_manager_service: LnChannelManagerService,
  ln_payment_service: LnPaymentService,
}

Pool Service Towers

struct Sv1MiningChannelService { ... }
struct Sv2MiningChannelService { ... }
struct JobDeclaratorService { ... }
struct TemplateReceiverService { ... }

impl tower::Service<Sv1MiningChannelRequest> { ... }
impl tower::Service<Sv2MiningChannelRequest> { ... }
impl tower::Service<JobDeclarationRequest> { ... }
impl tower::Service<TemplateReceiverRequest> { ... }

struct PoolTower {
  sv1_mining_channels_service: Sv1MiningChannelService,
  sv2_mining_channels_service: Sv2MiningChannelService,
  job_declarator_service: JobDeclaratorService,
  template_receiver_service: TemplateReceiverService
}
plebhash commented 3 months ago

Current Status:

there's a draft of Sv1MiningChannelService inside src/pool/service/sv1_mining_channel_service.rs (ln-pool-tower branch).

the idea there is to get the TcpListener to receive and decode Sv2Frame objects.

development is being driven around

RUST_LOG=debug cargo watch -c -x t

while unit tests leverage tower_test