message: fix: Transaction interface behavior inconsistency
diff: @@ -35,27 +35,24 @@ pub(crate) struct PoolRpcImpl<CS> {
  impl<CS: ChainStore + 'static> PoolRpc for PoolRpcImpl<CS> {
  fn send_transaction(&self, tx: Transaction) -> Result<H256> {
  let tx: CoreTransaction = tx.try_into().map_err(|_| Error::parse_error())?;
  - let tx_hash = tx.hash().clone();
  - let cycles = {
  +
  let mut chain_state = self.shared.chain_state().lock();
  let rtx = chain_state.resolve_tx_from_pool(&tx, &chain_state.tx_pool());
  - let tx_result =
  - chain_state.verify_rtx(&rtx, self.shared.consensus().max_block_cycles());
  + let tx_result = chain_state.verify_rtx(&rtx, self.shared.consensus().max_block_cycles());
  debug!(target: "rpc", "send_transaction add to pool result: {:?}", tx_result);
  - let cycles = match tx_result {
  - Err(TransactionError::Unknown) => None,
  - Err(err) => return Err(RPCError::custom(RPCError::Invalid, format!("{:?}", err))),
  - Ok(cycles) => Some(cycles),
  - };
  - let entry = PoolEntry::new(tx.clone(), 0, cycles);
  + match tx_result {
  + Err(TransactionError::UnknownInput) => Err(RPCError::custom(
  + RPCError::Staging,
  + "unknown inputs or deps".to_string(),
  + )),
  + Err(err) => Err(RPCError::custom(RPCError::Invalid, format!("{:?}", err))),
  + Ok(cycles) => {
  + let entry = PoolEntry::new(tx.clone(), 0, Some(cycles));
  + let tx_hash = tx.hash().clone();
  if !chain_state.mut_tx_pool().enqueue_tx(entry) {
  // Duplicate tx
  - return Ok(tx_hash);
  - }
  - cycles
  - };
  - match cycles {
  - Some(cycles) => {
  + Ok(tx_hash)
  + } else {
  let fbb = &mut FlatBufferBuilder::new();
  let message = RelayMessage::build_transaction(fbb, &tx, cycles);
  fbb.finish(message, None);
  @@ -74,10 +71,7 @@ impl<CS: ChainStore + 'static> PoolRpc for PoolRpcImpl<CS> {
  );
  Ok(tx_hash)
  }
  - None => Err(RPCError::custom(
  - RPCError::Staging,
  - "unknown inputs or deps".to_string(),
  - )),
  + }
  }
  }
  