{"action":"opened","issue":{"url":"https://api.github.com/repos/janearc/xact-id-tiny/issues/2","labels_url":"https://api.github.com/repos/janearc/xact-id-tiny/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/janearc/xact-id-tiny/issues/2/comments","events_url":"https://api.github.com/repos/janearc/xact-id-tiny/issues/2/events","html_url":"https://github.com/janearc/xact-id-tiny/issues/2","id":56939561,"number":2,"title":"promised transaction id's","user":{"login":"janearc","id":777319,"avatar_url":"https://avatars.githubusercontent.com/u/777319?v=3","gravatar_id":"","url":"https://api.github.com/users/janearc","html_url":"https://github.com/janearc","followers_url":"https://api.github.com/users/janearc/followers","following_url":"https://api.github.com/users/janearc/following{/other_user}","gists_url":"https://api.github.com/users/janearc/gists{/gist_id}","starred_url":"https://api.github.com/users/janearc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janearc/subscriptions","organizations_url":"https://api.github.com/users/janearc/orgs","repos_url":"https://api.github.com/users/janearc/repos","events_url":"https://api.github.com/users/janearc/events{/privacy}","received_events_url":"https://api.github.com/users/janearc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-08T05:17:59Z","updated_at":"2015-02-08T05:17:59Z","closed_at":null,"body":"so if we use something other than the builtin `nonce` function (because, say, we are storing things in riak) to generate transaction id's, do we break the interface here? if we look at [`riak-dc`](https://github.com/janearc/riak-dc/blob/master/lib/riak-dc.js#L302) we see that a *promise* to the serial is returned.\r\n\r\nthe problem is when we [say](https://github.com/janearc/xact-id-tiny/blob/master/test/02-new-xact.js):\r\n```javascript\r\nvar book = xit.book\r\n    , xact = new xit.xact();\r\n\r\n    xit.add( xact );\r\n```\r\nwhat happens under the covers is that `new xit.act()` runs `nonce()`. If we want `nonce()` to return the serial that e.g., riak gave us, we don't actually *know* the serial until `xit.add( xact )` happens, in the next statement, and `xit.add()` knows better than to \"add\" a transaction to the book without a transaction ID.\r\n\r\nA way around this would be to [force a key in Riak](https://github.com/janearc/riak-dc/blob/master/lib/riak-dc.js#L254), but the problem with forcing a key is that the whole idea of letting Riak designate keys to begin with is so we don't have this mickey-mouse call to crypto: `require('crypto').randomBytes(Math.ceil(16)).toString('hex')`.\r\n\r\nWhat makes this all the more curious is that Riak and Basho do a lot of talking about \"eventually-consistent\" things. So clearly they are aware of this sort of thing happening. Maybe the right solution is to have a `{ 'use-the-force': true }` or `{ 'trust-anonymous-transactions': true }` flag. It looks like a closure during [`book.add()`](https://github.com/janearc/xact-id-tiny/blob/master/lib/xit.js#L13) might actually do the trick. Or, if you see that the serial is a function (specifically if your serial is `typeof == 'function'` and `hasOwnPropery( 'then' )` you can probably feel certain that's a promise to your serial rather than \"the serial itself.\" And *eventual* serial, if you will."}}