message: support authed es
diff: use anyhow::Result;
  use clap::Clap;
  +use elasticsearch::auth::Credentials;
  use elasticsearch::http::transport::SingleNodeConnectionPool;
  use elasticsearch::http::Url;
  use elasticsearch::Elasticsearch;
  @@ -12,19 +13,24 @@ use starcoin_logger::prelude::*;
  use starcoin_rpc_api::chain::ChainClient;
  use std::time::Duration;
  use tokio_compat::runtime;
  +
  #[derive(Clap, Debug, Clone)]
  #[clap(version = "0.1.0", author = "Starcoin Core Dev <dev@starcoin.org>")]
  pub struct Options {
  #[clap(long, about = "es url", default_value = "http://localhost:9200")]
  es_url: Url,
  + #[clap(long, about = "es user used to call api", requires = "es-password")]
  + es_user: Option<String>,
  + #[clap(long, about = "es user password")]
  + es_password: Option<String>,
  + #[clap(long, about = "es index prefix", default_value = "starcoin")]
  + es_index_prefix: String,
  #[clap(
  long,
  about = "starcoin node rpc url",
  default_value = "http://localhost:9850"
  )]
  node_url: String,
  - #[clap(long, about = "es index prefix", default_value = "starcoin")]
  - es_index_prefix: String,
  }
  async fn start_loop(block_client: BlockClient, sinker: EsSinker) -> Result<()> {
  @@ -125,10 +131,16 @@ fn main() -> anyhow::Result<()> {
  .block_on(http::connect(opts.node_url.as_str()))
  .map_err(|e| e.compat())?;
  let block_client = BlockClient::new(channel);
  - let transport = elasticsearch::http::transport::TransportBuilder::new(
  + let mut transport = elasticsearch::http::transport::TransportBuilder::new(
  SingleNodeConnectionPool::new(opts.es_url),
  - )
  - .build()?;
  + );
  + if let Some(u) = opts.es_user.as_ref() {
  + let user = u.clone();
  + let pass = opts.es_password.unwrap_or_default();
  + transport = transport.auth(Credentials::Basic(user, pass));
  + }
  +
  + let transport = transport.build()?;
  let es = Elasticsearch::new(transport);
  let index_config = IndexConfig::new_with_prefix(opts.es_index_prefix.as_str());
  let sinker = EsSinker::new(es, index_config);
  