Article View: news.software.nntp
Article #64187Re: xBin Content-SHA1-Tree format
From: Stephen Lee
Date: Wed, 26 Feb 2003 15:59
Date: Wed, 26 Feb 2003 15:59
103 lines
5137 bytes
5137 bytes
What is the status of xBin? Is it in final form yet? If so, where (the docs)? Thanks, Steve "Curt Welch" <curt@kcwc.com> wrote in message news:20030225183939.804$fz@newsreader.com... > "Chris" <nobody@rogers.com> wrote: > > I've been writing an xBin implementation using python to see if I have my > > head wrapped around everything. Pretty much everything is straight > > forward except for how to include the necessary nodes from the complete > > hashtree. I came up with two algorithms for doing this. > > > > The first one is a bit more intuitive, but I think is harder to contruct > > and also makes verifying articles more complicated. Start out by making > > a new tree of the same size as your hashtree, with the leaf nodes having > > value 1 if that block is included in the article, and 0 if that block > > isn't covered. Then combine pairs of nodes to create the next level as > > in the hashtree. If either of the node's value is 1, then the parent's > > value is 1 also. This tree is supposed to represent which nodes we have > > knowledge about, or can generate its value from other known values. > > (I apologize for my diagrams in advance) > > > > hashtree: > > > > root > > /------\ > > H | > > /----\ | > > F G | > > /\ /\ | > > a b c d e > > > > a-e represent the hashes of the original data blocks > > F,G,H and root are the hashes we get when we combine the children. > > > > In this example, lets say we post an article containing blocks c,d. > > > > temporary tree: > > > > 1 > > /------\ > > 1 | > > /----\ | > > 0 1 | > > /\ /\ | > > 0 0 1 1 0 > > > > You then traverse the tree in a depth-first search. Any 0 you encounter > > means that you should include the corresponding node from the hashtree > > in the list of nodes in the header, and you can ignore any nodes below > > that node. If you encounter a 0 on the last level, you must include that > > node also. In this example, we must include nodes F and e in the xBin > > header. I assume that the root node will always be present in the > > header. > > The order that the nodes appear in is the same order as they are found > > in the depth first search. In this example it would be: > > Content-SHA1-Tree: root F e > > > > The second algorithm is much like the first, except it doesn't do the > > depth-first search. As you construct the temporary tree and combine > > siblings to form parents, if you combine a 0 node with a 1 node, then 0 > > node must be included in the headers. I believe this yields the same > > list of nodes as the first algorithm, but in a potentially different > > order. I think this algorithm is easier to implement. > > Both of these algorithms seem correct to me. > > > In either case it's important to have a well defined order for the > > Content-SHA1-Tree (if that's even what it should be called...it's not a > > tree anymore...) > > For sure. > > > What do people think? > > You did it in the same order I did. It's the obvious order. > > My posting code made one pass of the file and created the entire hash tree > first in-memory. Then as it posts each article, it would use the in-core > hash tree to generate the signature header. > > I wrote a recursive routine which did a depth-first scan like your first > algorithm. But, instead of building your 1/0 nodes, it figured that out by > keeping track of of the block range covered by each node. If you compare > the range of blocks covered by the current hash node you can figure out if > the node is a "1" node or a "0" node without wasting any time > pre-calculating that for each post. A 0 node is any node which includes > some of the blocks of the current article. All other nodes are 1 nodes. > > -- > Curt Welch http://CurtWelch.Com/ > curt@kcwc.com Webmaster for http://NewsReader.Com/
Technical Details
Message-ID:
<tv57a.134915$K71.75165@news1.central.cox.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!router1.news.adelphia.net!rip!news.webusenet.com!cox.net!p01!news1.central.cox.net.POSTED!53ab2750!not-for-mailReferences:
<pan.2003.02.25.15.32.50.152477@rogers.com> <20030225183939.804$fz@newsreader.com>Show Full Headers
Complete Article Headers
Message-ID: <tv57a.134915$K71.75165@news1.central.cox.net> Subject: Re: xBin Content-SHA1-Tree format Date: Wed, 26 Feb 2003 15:59:21 GMT From: "Stephen Lee" <slee@nospamtuxsoft.com> References: <pan.2003.02.25.15.32.50.152477@rogers.com> <20030225183939.804$fz@newsreader.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!router1.news.adelphia.net!rip!news.webusenet.com!cox.net!p01!news1.central.cox.net.POSTED!53ab2750!not-for-mail Newsgroups: news.software.nntp Lines: 102 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 68.102.73.136 X-Complaints-To: abuse@cox.net X-Trace: news1.central.cox.net 1046275161 68.102.73.136 (Wed, 26 Feb 2003 10:59:21 EST) NNTP-Posting-Date: Wed, 26 Feb 2003 10:59:21 EST Organization: Cox Communications