"Risin' up -- back on the street
Did my time, took my chances...
...They stack the odds still we take to the street
For the kill, with the skill to survive
It's the Eye of the Tiger
It's the Thrill of the fight..."
By Survivor - Eye Of The Tiger, Lyrics
It's a joke! I'm going to dig in my Tiger Tree Hashing algorithm implementation.
My work consists of five objects:
- HashInfo
- HashStore
- HashTree
- HashTreeRAF
- TTH
HashInfo holds HashTree metadata is not important in this post 'cause is only related to
JavaDC3 internal data communication model.
HashStore is a
singleton (GoF style). It is used to access the file in which are stored hash data: it uses
HashTreeRAF which represents the actual file, this last package local object that wraps
RandomAccessFile and it is used to read and write
HashTrees.
Here the problem to solve was that DC++ protocol exstensions requires that a client can download also multiple parts of a file or blocks (aka
"Segmented download"), so the need was to have a store which holds all Tree blocks hash datas. If you're familiar with C++ look at DC++ guys work
here.
You will see that thier and mine work are very similar. Actually, thier one is original... I learned by examples... Ok! I confess! I copied their work: I know this is not very noble but I had to make my client work the same way as DC++, and reading in C++ then writing in Java is not so simple!
HashTree is the ojbect that holds data of Hashed File. It is JavaDC3 internal rapresentation of a MerkleTree. Reading data from the Hash Store will create and "fill" a HashTree objects.
TTH computes the THEX TigerTree Algorithm, it relies on the implementation of the underlying Tiger algorithm from the Cryptix JCE
Marco