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.
파일 보기 프로젝트 열기: zencoders/sambatyon

공개 메소드들

메소드 설명
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