|
From: | Graydon Hoare |
Subject: | [Monotone-devel] Re: RFC: Fake IDs |
Date: | Wed, 19 Jul 2006 00:27:42 -0700 |
User-agent: | Thunderbird 1.5.0.4 (Windows/20060516) |
Nathaniel Smith wrote:
Well, as Zack mentioned, it is rather a pain to pass that database handle around everywhere (and it would be nice to pass it less places!). Furthermore, there are times when you don't really mean that anyway -- e.g., in the pluck code, I use 3 fake rids (for marking the synthetic ancestor/child/workspace rosters), and there _are_ no other rids in play, all I actually want is 3 rids that are distinct from each other. (Or maybe I actually use a real rid for one of those, since I happen to have it handy... it doesn't really matter, the point is that the constraint doesn't care about the rest of the db.)
Ok. I've argued with myself about my knee-jerk perception of risk here and convinced myself that I've been irrationally mis-perceiving relative probabilities. You're right: a fixed plaintext collision -- even all zero -- is actually *less* likely than the birthday-collision of "any two files". It's unnerving, but I have to accept the reasoning. Score one for unreasonable psychology.
I propose an Explicit and Sound Mechanism:Make a class fake_rid_source that wraps a u64 counter and sequentially assigns "%40.40llX" rids. Construct one and have it hand out fake rids within the scope that you're using them. That makes the scope relationships of your fakes somewhat explicit (which is half of what I wanted with "checking the database") and still lets you generate a few within a function and throw them out without dragging a db handle into it.
Good enough? -graydon
[Prev in Thread] | Current Thread | [Next in Thread] |