diff --git a/src/net/rpc.rs b/src/net/rpc.rs index f419939f7..203d1c36c 100644 --- a/src/net/rpc.rs +++ b/src/net/rpc.rs @@ -146,14 +146,10 @@ pub struct ConversationHttp { outbound_url: Option, peer_addr: SocketAddr, keep_alive: bool, - total_request_count: u64, - // number of messages taken from the inbox - total_reply_count: u64, - // number of messages responsed to - last_request_timestamp: u64, - // absolute timestamp of the last time we received at least 1 byte in a request - last_response_timestamp: u64, - // absolute timestamp of the last time we sent at least 1 byte in a response + total_request_count: u64, // number of messages taken from the inbox + total_reply_count: u64, // number of messages responsed to + last_request_timestamp: u64, // absolute timestamp of the last time we received at least 1 byte in a request + last_response_timestamp: u64, // absolute timestamp of the last time we sent at least 1 byte in a response connection_time: u64, // when this converation was instantiated canonical_stacks_tip_height: Option, // chain tip height of the peer's Stacks blockchain @@ -375,8 +371,8 @@ impl RPCPoxInfoData { let next_prepare_phase_in = i64::try_from(next_prepare_phase_start) .map_err(|_| net_error::ChainstateError("Burn block height overflowed i64".into()))? - i64::try_from(burnchain_tip.block_height).map_err(|_| { - net_error::ChainstateError("Burn block height overflowed i64".into()) - })?; + net_error::ChainstateError("Burn block height overflowed i64".into()) + })?; let cur_cycle_stacked_ustx = chainstate.get_total_ustx_stacked(&sortdb, tip, reward_cycle_id as u128)?; @@ -458,7 +454,7 @@ impl RPCNeighborsInfo { chain_view.burn_block_height, false, ) - .map_err(net_error::DBError)?; + .map_err(net_error::DBError)?; let sample: Vec = neighbor_sample .into_iter() @@ -1389,17 +1385,17 @@ impl ConversationHttp { ), Ok(Some(Err(e))) => match e { Unchecked(CheckErrors::CostBalanceExceeded(actual_cost, _)) - if actual_cost.write_count > 0 => - { - HttpResponseType::CallReadOnlyFunction( - response_metadata, - CallReadOnlyResponse { - okay: false, - result: None, - cause: Some("NotReadOnly".to_string()), - }, - ) - } + if actual_cost.write_count > 0 => + { + HttpResponseType::CallReadOnlyFunction( + response_metadata, + CallReadOnlyResponse { + okay: false, + result: None, + cause: Some("NotReadOnly".to_string()), + }, + ) + } _ => HttpResponseType::CallReadOnlyFunction( response_metadata, CallReadOnlyResponse { @@ -1672,7 +1668,7 @@ impl ConversationHttp { // present in the unconfirmed state? if let Some(ref unconfirmed) = chainstate.unconfirmed_state.as_ref() { if let Some((transaction, mblock_hash, seq)) = - unconfirmed.get_unconfirmed_transaction(txid) + unconfirmed.get_unconfirmed_transaction(txid) { let response = HttpResponseType::UnconfirmedTransaction( response_metadata, @@ -2635,14 +2631,14 @@ impl ConversationHttp { network.burnchain_tip.canonical_stacks_tip_height, )? { if let Some((consensus_hash, block_hash)) = - ConversationHttp::handle_load_stacks_chain_tip_hashes( - &mut self.connection.protocol, - &mut reply, - &req, - tip, - chainstate, - network.burnchain_tip.canonical_stacks_tip_height, - )? + ConversationHttp::handle_load_stacks_chain_tip_hashes( + &mut self.connection.protocol, + &mut reply, + &req, + tip, + chainstate, + network.burnchain_tip.canonical_stacks_tip_height, + )? { let accepted = ConversationHttp::handle_post_microblock( &mut self.connection.protocol, @@ -3502,21 +3498,21 @@ mod test { make_request: F, check_result: C, ) -> () - where - F: FnOnce( - &mut TestPeer, - &mut ConversationHttp, - &mut TestPeer, - &mut ConversationHttp, - ) -> HttpRequestType, - C: FnOnce( - &HttpRequestType, - &HttpResponseType, - &mut TestPeer, - &mut TestPeer, - &ConversationHttp, - &ConversationHttp, - ) -> bool, + where + F: FnOnce( + &mut TestPeer, + &mut ConversationHttp, + &mut TestPeer, + &mut ConversationHttp, + ) -> HttpRequestType, + C: FnOnce( + &HttpRequestType, + &HttpResponseType, + &mut TestPeer, + &mut TestPeer, + &ConversationHttp, + &ConversationHttp, + ) -> bool, { let mut peer_1_config = TestPeerConfig::new(test_name, peer_1_p2p, peer_1_http); let mut peer_2_config = TestPeerConfig::new(test_name, peer_2_p2p, peer_2_http); @@ -3525,13 +3521,13 @@ mod test { let privk1 = StacksPrivateKey::from_hex( "9f1f85a512a96a244e4c0d762788500687feb97481639572e3bffbd6860e6ab001", ) - .unwrap(); + .unwrap(); // STVN97YYA10MY5F6KQJHKNYJNM24C4A1AT39WRW let privk2 = StacksPrivateKey::from_hex( "94c319327cc5cd04da7147d32d836eb2e4c44f4db39aa5ede7314a761183d0c701", ) - .unwrap(); + .unwrap(); let microblock_privkey = StacksPrivateKey::new(); let microblock_pubkeyhash = Hash160::from_node_public_key(&StacksPublicKey::from_private(µblock_privkey)); @@ -3542,14 +3538,14 @@ mod test { 1, &vec![StacksPublicKey::from_private(&privk1)], ) - .unwrap(); + .unwrap(); let addr2 = StacksAddress::from_public_keys( C32_ADDRESS_VERSION_TESTNET_SINGLESIG, &AddressHashMode::SerializeP2PKH, 1, &vec![StacksPublicKey::from_private(&privk2)], ) - .unwrap(); + .unwrap(); peer_1_config.initial_balances = vec![ (addr1.to_account_principal(), 1000000000), @@ -3630,7 +3626,7 @@ mod test { &format!("hello-world-unconfirmed"), &unconfirmed_contract.to_string(), ) - .unwrap(), + .unwrap(), ); tx_unconfirmed_contract.chain_id = 0x80000000; @@ -3668,15 +3664,15 @@ mod test { &tip.sortition_id, &block.block_hash(), ) - .unwrap() - .unwrap(); // succeeds because we don't fork + .unwrap() + .unwrap(); // succeeds because we don't fork StacksChainState::get_anchored_block_header_info( chainstate.db(), &snapshot.consensus_hash, &snapshot.winning_stacks_block_hash, ) - .unwrap() - .unwrap() + .unwrap() + .unwrap() } }; @@ -3686,7 +3682,7 @@ mod test { tip.total_burn, microblock_pubkeyhash, ) - .unwrap(); + .unwrap(); let (anchored_block, anchored_block_size, anchored_block_cost) = StacksBlockBuilder::make_anchored_block_from_txs( block_builder, @@ -3694,7 +3690,7 @@ mod test { &sortdb.index_conn(), vec![tx_coinbase_signed.clone(), tx_contract_signed.clone()], ) - .unwrap(); + .unwrap(); anchor_size = anchored_block_size; anchor_cost = anchored_block_cost; @@ -3724,7 +3720,7 @@ mod test { &sort_iconn, BlockBuilderSettings::max_value(), ) - .unwrap(); + .unwrap(); let microblock = microblock_builder .mine_next_microblock_from_txs( vec![ @@ -3790,7 +3786,7 @@ mod test { 1, &vec![StacksPublicKey::from_private(&StacksPrivateKey::new())], ) - .unwrap(); + .unwrap(); let mut tx = StacksTransaction { version: TransactionVersion::Testnet, chain_id: 0x80000000, @@ -3831,7 +3827,7 @@ mod test { sponsor_nonce, None, ) - .unwrap(); + .unwrap(); } mempool_tx.commit().unwrap(); peer_2.mempool.replace(mempool); @@ -4114,7 +4110,7 @@ mod test { &stacks_block_id, &peer_client.config.burnchain, ) - .unwrap(); + .unwrap(); *pox_server_info.borrow_mut() = Some(pox_info); convo_client.new_getpoxinfo(TipRequest::UseLatestAnchoredTip) }, @@ -4171,7 +4167,7 @@ mod test { &stacks_block_id, &peer_client.config.burnchain, ) - .unwrap(); + .unwrap(); *pox_server_info.borrow_mut() = Some(pox_info); convo_client.new_getpoxinfo(TipRequest::UseLatestUnconfirmedTip) }, @@ -4476,7 +4472,7 @@ mod test { let privk = StacksPrivateKey::from_hex( "eb05c83546fdd2c79f10f5ad5434a90dd28f7e3acb7c092157aa1bc3656b012c01", ) - .unwrap(); + .unwrap(); let parent_block = make_codec_test_block(25); let parent_consensus_hash = ConsensusHash([0x02; 20]); @@ -4594,7 +4590,7 @@ mod test { let privk = StacksPrivateKey::from_hex( "eb05c83546fdd2c79f10f5ad5434a90dd28f7e3acb7c092157aa1bc3656b012c01", ) - .unwrap(); + .unwrap(); let parent_block = make_codec_test_block(25); let parent_consensus_hash = ConsensusHash([0x02; 20]); @@ -4708,7 +4704,7 @@ mod test { let privk = StacksPrivateKey::from_hex( "eb05c83546fdd2c79f10f5ad5434a90dd28f7e3acb7c092157aa1bc3656b012c01", ) - .unwrap(); + .unwrap(); let consensus_hash = ConsensusHash([0x02; 20]); let anchored_block_hash = BlockHeaderHash([0x03; 32]); @@ -4777,7 +4773,7 @@ mod test { let privk = StacksPrivateKey::from_hex( "eb05c83546fdd2c79f10f5ad5434a90dd28f7e3acb7c092157aa1bc3656b012c01", ) - .unwrap(); + .unwrap(); let sortdb = peer_server.sortdb.take().unwrap(); Relayer::setup_unconfirmed_state(peer_server.chainstate(), &sortdb).unwrap(); @@ -4825,7 +4821,7 @@ mod test { let tx = StacksTransaction::consensus_deserialize( &mut &hex_bytes(&unconfirmed_resp.tx).unwrap()[..], ) - .unwrap(); + .unwrap(); assert_eq!(tx.txid(), *last_txid.borrow()); true } @@ -4983,7 +4979,7 @@ mod test { let privk = StacksPrivateKey::from_hex( "eb05c83546fdd2c79f10f5ad5434a90dd28f7e3acb7c092157aa1bc3656b012c01", ) - .unwrap(); + .unwrap(); let consensus_hash = ConsensusHash([0x02; 20]); let anchored_block_hash = BlockHeaderHash([0x03; 32]); @@ -5610,7 +5606,7 @@ mod test { TupleData::from_data(vec![("units".into(), Value::Int(123))]) .unwrap() )) - .unwrap() + .unwrap() ); true } @@ -5679,7 +5675,7 @@ mod test { TupleData::from_data(vec![("units".into(), Value::Int(1))]) .unwrap() )) - .unwrap() + .unwrap() ); true } @@ -5738,7 +5734,7 @@ mod test { TupleData::from_data(vec![("units".into(), Value::Int(1))]) .unwrap() )) - .unwrap() + .unwrap() ); true }