pub struct AddrManImpl {
    pub cs: Mutex<AddrManInner>,
    pub n_key: u256,
    pub tried_collisions: HashSet<i32>,
    pub consistency_check_ratio: i32,
    pub asmap: Vec<bool>,
}

Fields§

§cs: Mutex<AddrManInner>

| A mutex to protect the inner data structures. |

§n_key: u256

| secret key to randomize bucket select | with |

§tried_collisions: HashSet<i32>

| Holds addrs inserted into tried table that | collide with existing | entries. Test-before-evict discipline used | to resolve these collisions.

§consistency_check_ratio: i32

| Perform consistency checks every | m_consistency_check_ratio operations (if | non-zero). |

§asmap: Vec<bool>

| Compressed IP->ASN mapping, loaded from | a file when a node starts. | | Should be always empty if no file was | provided. | | This mapping is then used for bucketing | nodes in Addrman. | | If asmap is provided, nodes will be | bucketed by AS they belong to, in order to | make impossible for a node to connect to | several nodes hosted in a single AS. | | This is done in response to Erebus attack, | but also to generally diversify the | connections every node creates, especially | useful when a large fraction of nodes | operate under a couple of cloud providers. | | If a new asmap was provided, the existing | records would be re-bucketed accordingly.

Implementations§

source§

impl AddrManImpl

source

pub fn new( asmap: Vec<bool>, deterministic: bool, consistency_check_ratio: i32 ) -> Self

source

pub fn len(&self) -> usize

source

pub fn add( &mut self, addrs: &Vec<Address>, source: &NetAddr, n_time_penalty: i64 ) -> bool

source

pub fn good(&mut self, addr: &Service, n_time: i64)

source

pub fn attempt(&mut self, addr: &Service, count_failure: bool, n_time: i64)

source

pub fn resolve_collisions(&mut self)

source

pub fn select_tried_collision(&mut self) -> (Address, i64)

source

pub fn select(&self, new_only: bool) -> (Address, i64)

source

pub fn get_addr( &self, max_addresses: usize, max_pct: usize, network: Option<Network> ) -> Vec<Address>

source

pub fn connected(&mut self, addr: &Service, n_time: i64)

source

pub fn set_services(&mut self, addr: &Service, n_services: ServiceFlags)

source

pub fn get_asmap(&self) -> &Vec<bool>

source§

impl AddrManImpl

source

pub fn serialize<Stream: GetVersion + GetType>(&self, stream: &mut Stream)

| Serialized format. | | - format version byte (@see Format) | | - lowest compatible format version | byte. This is used to help old software | decide whether to parse the file. For | example: | - Bitcoin Core version N knows how to | parse up to format=3. If a new format=4 | is introduced in version N+1 that is | compatible with format=3 and it is | known that version N will be able to | parse it, then version N+1 will write | (format=4, lowest_compatible=3) in the | first two bytes of the file, and so | version N will still try to parse it. | - Bitcoin Core version N+2 introduces | a new incompatible format=5. It will | write (format=5, lowest_compatible=5) | and so any versions that do not know | how to parse format=5 will not try to | read the file. | | - nKey | - n_new | - nTried | - number of “new” buckets XOR 230 | - all new addresses (total count: n_new) | - all tried addresses (total count: nTried) | - for each new bucket: | - number of elements | - for each element: index in the | serialized “all new addresses” | | - asmap checksum | | 230 is xorred with the number of buckets | to make addrman deserializer v0 detect it | as incompatible. This is necessary because | it did not check the version number on | deserialization. | | vvNew, vvTried, mapInfo, mapAddr and | vRandom are never encoded explicitly; they | are instead reconstructed from the other | information. | | This format is more complex, but | significantly smaller (at most 1.5 MiB), | and supports changes to the ADDRMAN_ | parameters without breaking the on-disk | structure. | | We don’t use SERIALIZE_METHODS since the | serialization and deserialization code has | very little in common.

source§

impl AddrManImpl

source

pub fn unserialize<Stream: GetType + GetVersion>( &mut self, s: &mut Stream ) -> Result<(), StdException>

Trait Implementations§

source§

impl Drop for AddrManImpl

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,

§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> StaticUpcast<T> for T

§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V