C# Класс Kademlia.BucketList

A list of contacts. Also responsible for storing last lookup times for buckets, so we can refresh them. Not thread safe for multiple people writing at once, since you can't enforce preconditions.
Показать файл Открыть проект

Открытые методы

Метод Описание
Blocker ( ID toAdd ) : Contact

Returns what contact is blocking insertion (least promoted), or null if no contact is.

BucketList ( ID ourID ) : System

Make a new bucket list, for holding node contacts.

CloseContacts ( ID target, ID excluded ) : List

Return a list of the BUCKET_SIZE contacts with IDs closest to target, not containing any contacts with the excluded ID.

CloseContacts ( int count, ID target, ID excluded ) : List

Returns a list of the specified number of contacts with IDs closest to the given key, excluding the excluded ID.

Contains ( ID toCheck ) : bool

See if we have a contact with the given ID.

Get ( ID toGet ) : Contact

Return the contact with the given ID, or null if it's not found.

GetCount ( ) : int

Return how many contacts are cached.

IDsForRefresh ( System.TimeSpan tooOld ) : IList

Gets a list of IDs that fall in buckets that haven't been written to in tooOld.

NodesToKey ( ID key ) : int

Return the number of nodes in the network closer to the key than us. This is a guess as described at http://xlattice.sourceforge.net/components/protocol/kademlia/specs.html

Promote ( ID toPromote ) : void

Move the contact with the given ID to the front of its bucket.

Put ( Contact toAdd ) : void

Add the given contact at the end of its bucket.

Remove ( ID toRemove ) : void

Remove a contact.

ToString ( ) : string

A ToString for debugging.

Touch ( ID key ) : void

Report that a lookup was done for the given key. Key must not match our ID.

Приватные методы

Метод Описание
BucketFor ( ID id ) : int

Returns what bucket an ID maps to. PRECONDITION: ourID not passed.

ForBucket ( int bucket ) : ID

Return an ID that belongs in the given bucket.

Описание методов

Blocker() публичный Метод

Returns what contact is blocking insertion (least promoted), or null if no contact is.
public Blocker ( ID toAdd ) : Contact
toAdd ID The node to add
Результат Contact

BucketList() публичный Метод

Make a new bucket list, for holding node contacts.
public BucketList ( ID ourID ) : System
ourID ID The ID to center the list on.
Результат System

CloseContacts() публичный Метод

Return a list of the BUCKET_SIZE contacts with IDs closest to target, not containing any contacts with the excluded ID.
public CloseContacts ( ID target, ID excluded ) : List
target ID The target to find the close node to
excluded ID The excluded ID
Результат List

CloseContacts() публичный Метод

Returns a list of the specified number of contacts with IDs closest to the given key, excluding the excluded ID.
public CloseContacts ( int count, ID target, ID excluded ) : List
count int The number of contacts to found
target ID The target node
excluded ID The excluded node
Результат List

Contains() публичный Метод

See if we have a contact with the given ID.
public Contains ( ID toCheck ) : bool
toCheck ID The ID to find into the structure
Результат bool

Get() публичный Метод

Return the contact with the given ID, or null if it's not found.
public Get ( ID toGet ) : Contact
toGet ID The ID of the contact to Get
Результат Contact

GetCount() публичный Метод

Return how many contacts are cached.
public GetCount ( ) : int
Результат int

IDsForRefresh() публичный Метод

Gets a list of IDs that fall in buckets that haven't been written to in tooOld.
public IDsForRefresh ( System.TimeSpan tooOld ) : IList
tooOld System.TimeSpan The timespan to discriminate
Результат IList

NodesToKey() публичный Метод

Return the number of nodes in the network closer to the key than us. This is a guess as described at http://xlattice.sourceforge.net/components/protocol/kademlia/specs.html
public NodesToKey ( ID key ) : int
key ID The key to analize
Результат int

Promote() публичный Метод

Move the contact with the given ID to the front of its bucket.
public Promote ( ID toPromote ) : void
toPromote ID The identificator of the contact to promote
Результат void

Put() публичный Метод

Add the given contact at the end of its bucket.
public Put ( Contact toAdd ) : void
toAdd Contact The new contact to add
Результат void

Remove() публичный Метод

Remove a contact.
public Remove ( ID toRemove ) : void
toRemove ID The identificator od the contact to remove
Результат void

ToString() публичный Метод

A ToString for debugging.
public ToString ( ) : string
Результат string

Touch() публичный Метод

Report that a lookup was done for the given key. Key must not match our ID.
public Touch ( ID key ) : void
key ID The bucket that refer the bucket to touch
Результат void