pass subscriber address when start gateway client

This commit is contained in:
ghassmo
2021-08-27 17:34:18 +03:00
parent e440409d81
commit 253bf174a5
2 changed files with 5 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ async fn start(executor: Arc<Executor<'_>>, config: Arc<CashierdConfig>) -> Resu
let wallet = Arc::new(CashierDb::new("cashier.db", config.password.clone())?);
debug!(target: "Client", "Creating gateway client");
let mut gateway = GatewayClient::new(gateway_addr, slabstore)?;
let mut gateway = GatewayClient::new(gateway_addr,"127.0.0.1:4444".parse()?, slabstore)?;
gateway.start().await?;

View File

@@ -182,10 +182,11 @@ pub struct GatewayClient {
gateway_slabs_sub_s: async_channel::Sender<Slab>,
gateway_slabs_sub_rv: GatewaySlabsSubscriber,
is_running: bool,
sub_addr: SocketAddr,
}
impl GatewayClient {
pub fn new(addr: SocketAddr, rocks: RocksColumn<columns::Slabs>) -> Result<Self> {
pub fn new(addr: SocketAddr, sub_addr: SocketAddr, rocks: RocksColumn<columns::Slabs>) -> Result<Self> {
let protocol = ReqProtocol::new(addr, String::from("GATEWAY CLIENT"));
let slabstore = SlabStore::new(rocks)?;
@@ -198,6 +199,7 @@ impl GatewayClient {
gateway_slabs_sub_s,
gateway_slabs_sub_rv,
is_running: false,
sub_addr,
})
}
@@ -287,10 +289,9 @@ impl GatewayClient {
pub async fn start_subscriber(
&self,
sub_addr: SocketAddr,
executor: Arc<Executor<'_>>,
) -> Result<GatewaySlabsSubscriber> {
let mut subscriber = Subscriber::new(sub_addr, String::from("GATEWAY CLIENT"));
let mut subscriber = Subscriber::new(self.sub_addr, String::from("GATEWAY CLIENT"));
subscriber.start().await?;
executor
.spawn(Self::subscribe_loop(