Use bee's state at diffStream creation time
The behaviour of the streams is unintuitive: the resulting stream can include entries not yet present at the time of creating the stream (no snapshot is taken). A straightforward solution: use snapshots when creating the stream. I think this conforms more to user expectation: when creating a diffStream, I expect the diffStream at the time I asked for it, not the diffStream of some future state of the bee.
Simple example:
const s1 = db.createDiffStream(1)
const s2 = db.createDiffStream(1)
const s1Added = []
const s2Added = []
for await (const elem of s1) { s1Added.push(elem) }
for await (const elem of s2) { s2Added.push(elem) }
// s2 can contain more elements than s2 in certain cases
See the test for how to trigger the race condition (it's tricky)
This applies to diffStream, readStream and historyStream. Holding off on implementing the fix for readStream and historyStream until sure the proposed solution is good.
Added a similar partial fix for createReadStream and createHistoryStream, but I'm not sure they are desired. They seem to solve the race condition (without those fixes the corresponding tests fail), but there could be more complications due to the feed.snapshot behaviour.