Difference between revisions of "P2pool util forest"

From Bitcoin Wiki
Jump to: navigation, search
(p2pool/util/forest.py)
(Skiplist, TrackerSkipList and DistanceSkipList classes)
 
(3 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
==Class Tracker==
 
==Class Tracker==
 
Number of dictionaries that store the shares in various ways to allow fast access.
 
Number of dictionaries that store the shares in various ways to allow fast access.
# shares (hash->share) Since share contains parent share allows you to link to previous shares all the way to the tail.
+
 
# reverse_shares (delta.tail->set of share_hashes) Allows you to link share to the next share that came after it all the way to the head.
+
This class is critical for performance. It stores and updates '''Deltas''' that are used for quickly answering queries by caching data between two points in the sharechain. Each share (item) has a delta that goes between it and its highest parent and contains information such as how much work was done and how many shares are in between. If the highest parent has its parent added, the delta will keep referring to the old highest parent until it is next needed, and then it will be updated.
# deltas (share_hash -> delta, ref)
+
 
# reverse_deltas (ref -> set of share_hashes)
+
Normally this class stores shares. These are called items in the code. I guess this is because the class is reused elsewhere?
 +
 
 +
# items (hash->item) Since share(item) contains parent share allows you to link to previous shares all the way to the tail.
 +
# reverse (delta.tail->set of item_hashes) Allows you to link share to the next share that came after it all the way to the head.
 +
# deltas (item_hash -> delta, ref)
 +
# reverse_deltas (ref -> set of item_hashes)
 
# delta_refs (ref -> delta)
 
# delta_refs (ref -> delta)
 
# reverse_delta_refs ( delta.tail -> ref)
 
# reverse_delta_refs ( delta.tail -> ref)
  
'''what are deltas???''' I have not got my head round this code at all!
+
 
 
===Method add===
 
===Method add===
 
Adds a share to the tracker
 
Adds a share to the tracker
 +
 +
===Skiplist, TrackerSkipList and DistanceSkipList classes===
 +
The __call__ function of DistanceSkipList implements the get_nth_parent_hash function of the trackers.
 +
So these are used to enable an efficient way of managing the share lists.
 +
 +
The trackers self._subset_of is a DistanceSkipList instance.
 +
TrackerSkipList is also the base class for data.py/WeightsSkipList class (should TrackerSkipList be moved into skiplist.py?)

Latest revision as of 20:48, 12 July 2012

This contains code for tracking shares.

Class Tracker

Number of dictionaries that store the shares in various ways to allow fast access.

This class is critical for performance. It stores and updates Deltas that are used for quickly answering queries by caching data between two points in the sharechain. Each share (item) has a delta that goes between it and its highest parent and contains information such as how much work was done and how many shares are in between. If the highest parent has its parent added, the delta will keep referring to the old highest parent until it is next needed, and then it will be updated.

Normally this class stores shares. These are called items in the code. I guess this is because the class is reused elsewhere?

  1. items (hash->item) Since share(item) contains parent share allows you to link to previous shares all the way to the tail.
  2. reverse (delta.tail->set of item_hashes) Allows you to link share to the next share that came after it all the way to the head.
  3. deltas (item_hash -> delta, ref)
  4. reverse_deltas (ref -> set of item_hashes)
  5. delta_refs (ref -> delta)
  6. reverse_delta_refs ( delta.tail -> ref)


Method add

Adds a share to the tracker

Skiplist, TrackerSkipList and DistanceSkipList classes

The __call__ function of DistanceSkipList implements the get_nth_parent_hash function of the trackers. So these are used to enable an efficient way of managing the share lists.

The trackers self._subset_of is a DistanceSkipList instance. TrackerSkipList is also the base class for data.py/WeightsSkipList class (should TrackerSkipList be moved into skiplist.py?)