crate::ix!();
pub fn make_node(context: &mut dyn NodeContextInterface) -> Box<Node> {
todo!();
}
pub struct Node {
pub deserializer: Option<Box<dyn TransportDeserializer>>,
pub serializer: Option<Box<dyn TransportSerializer>>,
pub permission_flags: NetPermissionFlags,
pub n_services: Atomic<ServiceFlags>,
pub cs_v_send: Arc<Mutex<NodeVSend>>,
pub cs_h_socket: Arc<Mutex<NodeHSocket>>,
pub cs_v_recv: Arc<Mutex<NodeVRecv>>,
pub cs_v_process_msg: Arc<Mutex<NodeVProcessMsg>>,
pub n_process_queue_size: AtomicUsize,
pub cs_send_processing: RawMutex,
pub n_last_send: Atomic<Option<OffsetDateTime>>,
pub n_last_recv: Atomic<Option<OffsetDateTime>>,
pub n_time_connected: Atomic<Option<OffsetDateTime>>,
pub n_time_offset: Atomic<Option<Duration>>,
pub addr: Address,
pub addr_bind: Address,
pub addr_name: String,
pub inbound_onion: bool,
pub n_version: AtomicI32,
pub clean_sub_ver: Arc<Mutex<String>>,
pub prefer_evict: bool,
pub client: bool,
pub limited_node: bool,
pub successfully_connected: AtomicBool,
pub disconnect: AtomicBool,
pub grant_outbound: SemaphoreGrant,
pub n_ref_count: AtomicI32,
pub n_keyed_net_group: u64,
pub pause_recv: AtomicBool,
pub pause_send: AtomicBool,
pub bip152_highbandwidth_to: AtomicBool,
pub bip152_highbandwidth_from: AtomicBool,
pub tx_relay: Amo<NodeTxRelay>,
pub n_last_block_time: Atomic<Option<OffsetDateTime>>,
pub n_last_tx_time: Atomic<Option<OffsetDateTime>>,
pub last_ping_time: Atomic<Option<Instant>>,
pub min_ping_time: Atomic<Option<Duration>>,
pub id: NodeId,
pub n_local_host_nonce: u64,
pub conn_type: Option<ConnectionType>,
pub greatest_common_version: AtomicI32,
pub n_local_services: ServiceFlags,
pub recv_msg: Arc<Mutex<Vec<NetMessage>>>,
pub cs_addr_local: Arc<Mutex<NodeAddrLocal>>,
}
impl PartialEq for Node {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
impl Eq for Node {}
impl Default for Node {
fn default() -> Self {
Self {
deserializer: None,
serializer: None,
permission_flags: NetPermissionFlags::None,
n_services: Atomic::new(ServiceFlags::NODE_NONE),
cs_v_send: Arc::new(Mutex::<NodeVSend>::default()),
cs_h_socket: Arc::new(Mutex::<NodeHSocket>::default()),
cs_v_recv: Arc::new(Mutex::<NodeVRecv>::default()),
cs_v_process_msg: Arc::new(Mutex::new(NodeVProcessMsg::default())),
n_process_queue_size: AtomicUsize::new(0),
cs_send_processing: RawMutex::INIT,
n_last_send: Atomic::new(None),
n_last_recv: Atomic::new(None),
n_time_connected: Atomic::new(None),
n_time_offset: Atomic::new(None),
addr: Address::default(),
addr_bind: Address::default(),
addr_name: String::default(),
inbound_onion: false,
n_version: AtomicI32::new(0),
clean_sub_ver: Default::default(),
prefer_evict: false,
client: false,
limited_node: false,
successfully_connected: AtomicBool::new(false),
disconnect: AtomicBool::new(false),
grant_outbound: SemaphoreGrant::default(),
n_ref_count: AtomicI32::new(0),
n_keyed_net_group: 0,
pause_recv: AtomicBool::new(false),
pause_send: AtomicBool::new(false),
bip152_highbandwidth_to: AtomicBool::new(false),
bip152_highbandwidth_from: AtomicBool::new(false),
tx_relay: Amo::<NodeTxRelay>::none(),
n_last_block_time: Atomic::new(None),
n_last_tx_time: Atomic::new(None),
last_ping_time: Atomic::<Option::<Instant>>::new(None),
min_ping_time: Atomic::<Option::<Duration>>::new(None),
id: NodeId::default(),
n_local_host_nonce: 0,
conn_type: None,
greatest_common_version: AtomicI32::new(INIT_PROTO_VERSION),
n_local_services: ServiceFlags::default(),
recv_msg: Arc::new(Mutex::new(Vec::<NetMessage>::default())),
cs_addr_local: Arc::new(Mutex::<NodeAddrLocal>::default()),
}
}
}
unsafe impl Send for Node {}
unsafe impl Sync for Node {}
impl Drop for Node {
fn drop(&mut self) {
todo!();
}
}
impl GetNodeId for Node {
fn get_id(&self) -> NodeId {
todo!();
}
}
impl IsBlockOnlyConn for Node {
fn is_block_only_conn(&self) -> bool {
todo!();
}
}
impl IsInboundConn for Node {
fn is_inbound_conn(&self) -> bool {
todo!();
}
}
impl GetNTimeConnected for Node {
#[inline] fn get_n_time_connected(&self) -> OffsetDateTime {
self.n_time_connected
.load(atomic::Ordering::Relaxed).unwrap()
}
}
impl IsOutboundOrBlockRelayConn for Node {
fn is_outbound_or_block_relay_conn(&self) -> bool {
todo!();
}
}
impl IsFullOutboundConn for Node {
fn is_full_outbound_conn(&self) -> bool {
todo!();
}
}
impl IsManualConn for Node {
fn is_manual_conn(&self) -> bool {
todo!();
}
}
impl IsFeelerConn for Node {
fn is_feeler_conn(&self) -> bool {
todo!();
}
}
impl IsAddrFetchConn for Node {
fn is_addr_fetch_conn(&self) -> bool {
todo!();
}
}
impl MarkForDisconnect for Node {
fn mark_for_disconnect(&self) {
self.disconnect.store(true, atomic::Ordering::Relaxed);
}
}
impl GetServiceRef for Node {
fn service(&self) -> &Service {
&self.addr.service
}
}
impl GetServiceMut for Node {
fn service_mut(&mut self) -> &mut Service {
&mut self.addr.service
}
}
impl GetAddrRef for Node {
fn addr(&self) -> &Address {
&self.addr
}
}
impl GetAddrMut for Node {
fn addr_mut(&mut self) -> &mut Address {
&mut self.addr
}
}
impl GetLocalServices for Node {
fn get_local_services(&self) -> ServiceFlags {
todo!();
}
}
impl GetLocalNonce for Node {
fn get_local_nonce(&self) -> u64 {
todo!();
}
}
impl GetCommonVersion for Node {
fn get_common_version(&self) -> i32 {
todo!();
}
}
impl MarkedForDisconnect for Node {
fn marked_for_disconnect(&self) -> bool {
self.disconnect.load(atomic::Ordering::Relaxed)
}
}
impl HasPermission for Node {
fn has_permission(&self, permission: NetPermissionFlags) -> bool {
todo!();
}
}
impl GetTxRelay for Node {
fn get_tx_relay(&self) -> AmoReadGuard<NodeTxRelay> {
self.tx_relay.get()
}
}
impl GetTxRelayMut for Node {
fn get_tx_relay_mut(&self) -> AmoWriteGuard<NodeTxRelay> {
self.tx_relay.get_mut()
}
}
impl HasTxRelay for Node {
fn has_tx_relay(&self) -> bool {
self.tx_relay.is_some()
}
}
impl DisconnectOnStall for Node {
fn disconnect_on_stall(&self) {
log_printf!(
"Peer=%d is stalling block download, disconnecting\n",
self.get_id()
);
self.disconnect.store(true, atomic::Ordering::Relaxed);
}
}
impl NVersion for Node {
fn n_version(&self) -> i32 {
self.n_version.load(atomic::Ordering::Relaxed)
}
}
impl SetSuccessfullyConnected for Node {
fn set_successfully_connected(&self, val: bool) {
self.successfully_connected.store(val, atomic::Ordering::Relaxed);
}
}
impl IsSuccessfullyConnected for Node {
fn is_successfully_connected(&self) -> bool {
self.successfully_connected.load(atomic::Ordering::Relaxed)
}
}
impl ExpectServicesFromConn for Node {
fn expect_services_from_conn(&self) -> bool {
todo!();
}
}
impl AddKnownTx for Node {
fn add_known_tx(&mut self, hash: &u256) {
todo!();
}
}
impl PongReceived for Node {
fn pong_received(&mut self, ping_time: Duration ) {
todo!();
}
}
impl SetCommonVersion for Node {
fn set_common_version(&mut self, greatest_common_version: i32) {
todo!();
}
}
impl SetAddrLocal for Node {
fn set_addr_local(&mut self, addr_local_in: &Service) {
todo!();
}
}
impl SetNLastBlockTime for Node {
fn set_n_last_block_time(&mut self, x: Option<OffsetDateTime>) {
self.n_last_block_time.store(x, atomic::Ordering::Relaxed);
}
}
impl SendPaused for Node {
fn send_paused(&self) -> bool {
self.pause_send.load(atomic::Ordering::Relaxed)
}
}
impl IsClient for Node {
fn is_client(&self) -> bool {
self.client
}
}
impl SetIsClient for Node {
fn set_is_client(&mut self, x: bool) {
self.client = x;
}
}
impl IsLimitedNode for Node {
fn is_limited_node(&self) -> bool {
self.limited_node
}
}
impl SetLimitedNode for Node {
fn set_limited_node(&mut self, x: bool) {
self.limited_node = x;
}
}
impl SetNTimeOffset for Node {
fn set_n_time_offset(&mut self, x: Option<Duration>) {
self.n_time_offset.store(x, atomic::Ordering::Relaxed);
}
}
impl SetNLastTxTime for Node {
fn set_n_last_tx_time(&mut self, x: Option<OffsetDateTime>) {
self.n_last_tx_time.store(x, atomic::Ordering::Relaxed);
}
}
impl SetBip152HighBandwidthFrom for Node {
fn set_bip152_highbandwidth_from(&mut self, x: bool) {
self.bip152_highbandwidth_from.store(x, atomic::Ordering::Relaxed);
}
}
impl SetBip152HighBandwidthTo for Node {
fn set_bip152_highbandwidth_to(&mut self, x: bool) {
self.bip152_highbandwidth_to.store(x, atomic::Ordering::Relaxed);
}
}
impl DecrementNProcessQueueSize for Node {
fn decrement_n_process_queue_size(&self, val: usize) {
self.n_process_queue_size.fetch_sub(val, atomic::Ordering::Relaxed);
}
}
impl GetNProcessQueueSize for Node {
fn get_n_process_queue_size(&self) -> usize {
self.n_process_queue_size.load(atomic::Ordering::Relaxed)
}
}
impl SetPauseRecv for Node {
fn set_pause_recv(&self, x: bool) {
self.pause_recv.store(x, atomic::Ordering::Relaxed)
}
}
impl LockVProcessMsg for Node {
fn lock_v_process_msg(&self) -> MutexGuard<NodeVProcessMsg> {
self.cs_v_process_msg.lock()
}
}
impl SetNServices for Node {
fn set_n_services(&mut self, x: ServiceFlags) {
self.n_services.store(x, atomic::Ordering::Relaxed);
}
}
impl SetNVersion for Node {
fn set_n_version(&mut self, x: i32) {
self.n_version.store(x, atomic::Ordering::Relaxed);
}
}
impl SetCleanSubVer for Node {
fn set_clean_sub_ver(&mut self, x: &str) {
*self.clean_sub_ver.lock() = x.to_string();
}
}
impl Node {
pub fn new(
id_in: NodeId,
n_local_services_in: ServiceFlags,
h_socket_in: CSocket,
addr_in: &Address,
n_keyed_net_group_in: u64,
n_local_host_nonce_in: u64,
addr_bind_in: &Address,
addr_name_in: &String,
conn_type_in: ConnectionType,
inbound_onion: bool) -> Self {
todo!();
}
pub fn get_addr_local(&self) -> Service {
todo!();
}
pub fn connection_type_as_string(&self) -> String {
todo!();
}
}
impl ConnType for Node {
fn conn_type(&self) -> Option<ConnectionType> {
self.conn_type
}
}
impl NTimeConnected for Node {
fn n_time_connected(&self) -> Option<OffsetDateTime> {
self.n_time_connected.load(atomic::Ordering::Relaxed)
}
}
impl MinPingTime for Node {
fn min_ping_time(&self) -> Option<Duration> {
self.min_ping_time.load(atomic::Ordering::Relaxed)
}
}
impl NLastBlockTime for Node {
fn n_last_block_time(&self) -> Option<OffsetDateTime> {
self.n_last_block_time.load(atomic::Ordering::Relaxed)
}
}
impl NLastTxTime for Node {
fn n_last_tx_time(&self) -> Option<OffsetDateTime> {
self.n_last_tx_time.load(atomic::Ordering::Relaxed)
}
}
impl NServices for Node {
fn n_services(&self) -> ServiceFlags {
self.n_services.load(atomic::Ordering::Relaxed)
}
}
impl NKeyedNetGroup for Node {
fn n_keyed_net_group(&self) -> u64 {
self.n_keyed_net_group
}
}
impl PreferEvict for Node {
fn prefer_evict(&self) -> bool {
self.prefer_evict
}
}
impl ConnectedThroughNetwork for Node {
fn connected_through_network(&self) -> Network {
todo!();
}
}
impl SuccessfullyConnected for Node {
fn successfully_connected(&self) -> bool {
self.successfully_connected.load(atomic::Ordering::Relaxed)
}
}
impl NodeInterfaceAddRef for Node {
fn add_ref(&mut self) -> *mut dyn NodeInterface {
todo!();
}
}
impl SetPermissionFlags for Node {
fn set_permission_flags(&mut self, x: NetPermissionFlags) {
self.permission_flags = x;
}
}
impl SetPreferEvict for Node {
fn set_prefer_evict(&mut self, x: bool) {
self.prefer_evict = x;
}
}
impl ReleaseGrantOutbound for Node {
fn release_grant_outbound(&mut self) {
self.grant_outbound.release();
}
}
impl CloseSocketDisconnect for Node {
fn close_socket_disconnect(&mut self) {
todo!();
}
}
impl Release for Node {
fn release(&mut self) {
todo!();
}
}
impl GetRefCount for Node {
fn get_ref_count(&self) -> i32 {
todo!();
}
}
impl AddrName for Node {
fn addr_name(&self) -> &str {
self.addr_name.as_str()
}
}
impl PauseRecv for Node {
fn pause_recv(&self) -> bool {
self.pause_recv.load(atomic::Ordering::Relaxed)
}
}
impl LockVSend for Node {
fn lock_v_send(&self) -> MutexGuard<NodeVSend> {
self.cs_v_send.lock()
}
}
impl LockHSocket for Node {
fn lock_h_socket(&self) -> MutexGuard<NodeHSocket> {
self.cs_h_socket.lock()
}
}
impl CopyStats for Node {
fn copy_stats(&mut self, stats: &mut NodeStats) {
macro_rules! x {
($name:ident) => {
}
}
todo!();
}
}
impl AddrBind for Node {
fn addr_bind(&self) -> &Address {
&self.addr_bind
}
}
impl NLastRecv for Node {
fn n_last_recv(&self) -> Option<OffsetDateTime> {
self.n_last_recv.load(atomic::Ordering::Relaxed)
}
}
impl NLastSend for Node {
fn n_last_send(&self) -> Option<OffsetDateTime> {
self.n_last_send.load(atomic::Ordering::Relaxed)
}
}
impl GrantOutbound for Node {
fn grant_outbound(&self) -> SemaphoreGrant {
self.grant_outbound.clone()
}
}
impl GetTransportSerializer for Node {
fn get_transport_serializer(&self) -> &Box<dyn TransportSerializer> {
self.serializer.as_ref().unwrap()
}
}
impl GetTransportSerializerMut for Node {
fn get_transport_serializer_mut(&mut self) -> &mut Box<dyn TransportSerializer> {
self.serializer.as_mut().unwrap()
}
}
impl SetPauseSend for Node {
fn set_pause_send(&self, x: bool) {
self.pause_send.store(x, atomic::Ordering::Relaxed);
}
}
impl ReceiveMsgBytes for Node {
fn receive_msg_bytes(&mut self,
msg_bytes: &[u8],
complete: &mut bool) -> bool {
todo!();
}
}
impl LockRecvMsg for Node {
fn lock_recv_msg(&self) -> MutexGuard<Vec<NetMessage>> {
self.recv_msg.lock()
}
}
impl IncrementNProcessQueueSize for Node {
fn increment_n_process_queue_size(&self, x: usize) {
self.n_process_queue_size.fetch_add(x, atomic::Ordering::Relaxed);
}
}
impl NProcessQueueSize for Node {
fn n_process_queue_size(&self) -> usize {
self.n_process_queue_size.load(atomic::Ordering::Relaxed)
}
}
impl LockSendProcessing for Node {
unsafe fn lock_send_processing(&self) {
self.cs_send_processing.lock();
}
}
impl UnlockSendProcessing for Node {
unsafe fn unlock_send_processing(&self) {
self.cs_send_processing.unlock();
}
}
impl PushTxInventory for Node {
fn push_tx_inventory(&mut self, hash: &u256) {
todo!();
}
}