C# Class 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.
Afficher le fichier Open project: zencoders/sambatyon

Méthodes publiques

Méthode Description
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.

Private Methods

Méthode Description
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.

Method Details

Blocker() public méthode

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
Résultat Contact

BucketList() public méthode

Make a new bucket list, for holding node contacts.
public BucketList ( ID ourID ) : System
ourID ID The ID to center the list on.
Résultat System

CloseContacts() public méthode

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
Résultat List

CloseContacts() public méthode

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
Résultat List

Contains() public méthode

See if we have a contact with the given ID.
public Contains ( ID toCheck ) : bool
toCheck ID The ID to find into the structure
Résultat bool

Get() public méthode

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
Résultat Contact

GetCount() public méthode

Return how many contacts are cached.
public GetCount ( ) : int
Résultat int

IDsForRefresh() public méthode

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
Résultat IList

NodesToKey() public méthode

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
Résultat int

Promote() public méthode

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
Résultat void

Put() public méthode

Add the given contact at the end of its bucket.
public Put ( Contact toAdd ) : void
toAdd Contact The new contact to add
Résultat void

Remove() public méthode

Remove a contact.
public Remove ( ID toRemove ) : void
toRemove ID The identificator od the contact to remove
Résultat void

ToString() public méthode

A ToString for debugging.
public ToString ( ) : string
Résultat string

Touch() public méthode

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
Résultat void