That's an interesting idea! I also think that we probably shouldn't hash nameindex.dat (BDB data file?) directly, but rather think about a simple, clean (and explicitly specified/documented somewhere!) way to perform the hash of all current names. What about using the same idea about Merkle trees that is used already for transactions in a block? Not sure if that makes sense for the list of names itself, but possibly this could be used for the namespaces. That way, it would even be possible to develop light clients that only know about names in d/ (for instance) and ignore all others. Basically it could work like this:
For all names in a namespace:
For each (non-expired?) name, hash its value; then produce a file of them form:
Code: Select all
d/myname: HASH-OF-VALUE
d/xyz: HASH-OF-VALUE
...
where the lines appear in a well-defined order (e. g., sorted lexically by name). Hash this file to produce a "master hash" for the d/ namespace.
For all namespaces:
Again write up a file of a form like this:
Code: Select all
d: HASH-OF-NAMESPACE
id: HASH-OF-NAMESPACE
...
Hash this file, too.
Of course, the actual forms of how things are hashed in detail are not important and could be changed to something else. The final hash of the namespace file will then be included by miners in some block, or even every block (as part of the block header or simply the tx merkle tree - would not even require a hard fork?). Then every node that has a current list of name-value pairs for some namespace plus a list of all namespaces with their master hashes can easily verify that this list is indeed correct as of a certain block height.
If we do a full protocol extension, we may even make full nodes serve this list upon request to other nodes, so that light clients don't even need an additional source for the data (like a Torrent). I think the name index should be relatively small, shouldn't it? Of course, if it grows too large, one can also have each node only honour requests for a limited number of names at a time, so that a light client must query multiple nodes over time to get a full list. This shouldn't be a big deal, though.
Finally, we could (at least I think so) even produce a tree of some kind (e. g., balanced binary tree) from the names and create a "real" Merkle tree of all names. That way, a light client need only query some other node for a single name plus its tree branch in order to get a (provably correct) value for it! (I think this is exactly how SVP clients in Bitcoin handle transactions; I don't see why it wouldn't work also for querying names.)