Great work, I just have a question about the span. I don't understand how it works, because if you fork the block chain, won't all the existing span numbers have to be incremented?
I've been trying to implement a sqlite backend (so far just dump to sqlite which is mostly working), and it seems to be helpful to distinguish between dynamic data and data which is immutable such as the successor relationship between blocks, transaction containment within a block, etc.
Whether a block is in the best chain and whether a txout has been spent in the best chain is dynamic, so I have to implement queries that more or less correspond to ConnectBlock and DisconnectBlock. I would love to be able to eliminate it using your span mechanism or something similar but I'm not understanding how it works.