Please check out this branch and give this first pass (work in progress) a try. This branch adds the following two functions:
bundleStart(timeout,userParam) and bundleClose(commit)
The first begins the bundle, and any subsequent commits until a call to bundleClose will not be added to the chain until a call to bundleClose(true) is made. To cancel the bundle call `bundleClose(false).
There is a callback: bundleCanceled(reason,userParam) which will be called if the bundle is canceled. From this callback you must return either HC.BundleCancel.Response.OK if you want the cancel to proceed, HC.BundleCancel.Response.Commit if you want the cancel to be canceled and instead have the bundle committed.
reason could be either: HC.BundleCancel.Reason.UserCancel or HC.BundleCancel.Reason.Timeout
Not yet implemented:
- timeout doesn't work
- any commits during bundle will actually get pushed to the DHT (i.e. I haven't queued the puts for sending on bundleClose yet, but please don't let this stop you from testing this out as I'll get that done next)
- query() doesn't look in the bundle yet. Question: should query() behave as if everything in the bundle actually exists, or should I add an explicit parameter for it to search the bundle
- get(hash,{Local:true}) doesn't look in the bundle yet
- there is currently no protection from a concurrent call via the UI from adding commits to the middle of your bundle, beware!
Feedback appreciated.