-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript Driver #256
Comments
Looks like a good start. I would remove the checkboxes from the Later section so that this issue is "done" (5 out of 5) once the first five checkboxes get checked. The later things can go in future "project" issues with their own checkboxes. |
@ttmc yes, that's a really good point. I'll remove the checkboxes and put a normal list, so I can copy paste it to the next project 💃 |
OK so here are a few things:
Mongojs
node-postgres
node-mysql
redis-node
couchdb
|
It might be nice to have separate repos for different drivers, or even a drivers repo, rather than keeping it all in this repo. Just a thought. |
I want to wrap some basic features, like generating a key pair, to make it easy to create entities and exchange assets between them. If you already have a key pair, you can still use it.
The idea is to keep the driver as easy as possible. Right now the few functions I'm thinking about are
The driver might need to verify some transactions made by the nodes in the federation. Anyway, I'm not 100% sure of this use case. @r-marques any thoughts on this?
Right, it was in my head but not in the proposal 😅. Promises for sure. I'll update the proposal now (do you suggest using
Wow, thanks a lot for the examples. In this case we don't have a wire protocol, but just http requests, so you don't really "connect" to BigchainDB. This might change in the future if we decide to have a different way to talk to the federation. |
IMO it's a bit simpler to keep stuff in the same repo to manage issues and revisions. |
@TimDaub related to promises, I was thinking something like: var keypair = bigchaindb.generateKeypair();
var alice = bigchaindb.session(keypair, config);
alice.create({asset: 'whatever'})
.then(response => {
console.log(`Transaction "${response.transaction.id}" has been submitted.`);
})
.catch(err => {
console.log(`There was an error while processing the transaction: "${err}"`);
}); There is another problem anyway. The lifecycle of a transaction is:
Right now the promise returns when the transaction has been accepted by the Federation. We need another mechanism to notify the user when the transaction moves from undecided to valid or invalid. This can be generalized in the future using a websocket for asynchronous communications. @r-marques any thoughts on that? |
In favour of having at least a drivers repo. |
Also have a look at the interledger project: Some specifically interesting repo's |
We'll have to figure out what will be the final syntax - but I guess it will be resembling the python client language? |
The Python driver code will probably share some code with the BigchainDB server code, so having them in separate repos would be a pain. Maybe the Python driver is a special case though, and all other drivers can go in another repo (or set of repos). RethinkDB has all their supported drivers in a subdirectory named |
👍 I can see two main use cases for this driver:
In use case one, all your business logic is residing in your backend. If something needs to be executed, certain conditions need to be valued to not make your data inconsistent. What you'd like to do in that case is create a transaction, push it to the client. The client signs it on his computer by generating his privatekey on the fly and sends it back to the server. Transaction gets pushed to the federation by the backend. SPOOL would be an example of this use case. In use case two, all your business logic is residing in the frontend. A backend might not even be needed.
Little bit out of the loop, but all the cool kids from the block use https://github.com/petkaantonov/bluebird right now, I heard.
Does it really matter?
Great point! All a federation node could do right now, is to send a Something like: Notify me about all transactions that relate to one of my public keys As a side note, Ethereum has a really cool concept of notifying the outside world about stuff (not sure how applicable this is in our case):
Great point. What is the relation of this client and cryptoconditions? Does it allow me to do all the things, cryptoconditions (I'm speaking of their JS implementation) let me? |
Unless we really find ourselves needing the extra features from the other promise libraries, I'd prefer using ES2015 promises. This way you won't force your choice on other's projects, and if they really want to use one of the other libraries, they can always wrap the promises we return with their library of choice or, with some configuration, override the |
@diminator: thanks, this is pretty interesting!
@diminator: for this first iteration I want to focus on few use cases, once they are there we can decide if we like the API and iterate from that :)
@troy: should not be a problem anyway to keep it in a different repo anyway, since the dependencies are defined in
@TimDaub: Good use cases, thanks!
@TimDaub: IMO yes. A connection is something that might need a pool (of connections), or can be lost, etc :)
@TimDaub: Yup, the Federation Nodes can expose a pubsub API. The Driver can subscribe to specific events to it's own key or more.
@TimDaub: the Driver is just a handy tool to connect to the Federation and push some transactions. The Driver ease the creation of transactions for the common cases. If the user has more specific needs, they will always be able to create cryptoconditions by hand /cc @diminator
@sohkai: do I need to use a shim? Maybe we can talk a second about that. |
For everyone external looking at this ticket: @sohkai has developed a minimal viable JS library to build bigchaindb transactions here: https://github.com/sohkai/js-bigchaindb-quickstart EDITWe're now officially supporting a javascript driver here: https://github.com/bigchaindb/js-bigchaindb-driver |
this issue here is the first result coming up when I google for |
Good point. @kremalicious Diwcoverability and SEO is important. You've created a ticket on the driver. Great. Also, I'll close this ticket as I largely consider it done (we should/can still take it as a starting point for the js-bigchaindb-driver). |
Abstract
BigchainDB misses an official implementation for the JavaScript Driver.
Release 0.3 introduces cryptoconditions and a new format for creating and signing transactions. Since this won't change soon, it's a good time to develop a JS Driver.
Goals
The goal is to have a package developers can use both for client (browser) and server (Node.js) applications.
This should be feasible (and have acceptable performance in a browser) since the JavaScript implementation of cryptoconditions uses TweetNaCl, a self-contained, small crypto library that can run in the browser.
This project follows the ascribe JavaScript Style Guide and will be stored in the BigchainDB repository, under the
drivers/javascript
directory.Challenges
When running the Driver from the browser, we must consider the following challenges:
Architecture
While most of the code will be shared between the browser and the Node.js implementation, there will be few platform specific functions, in particular the one to load keys.
Examples
Here are some examples on how the interface will look like.
Roadmap
Deadline
May 12thTBDThere has been more discussion than expected (which is a good thing, actually). I just put TBD on the deadline, but will update it soon.
CREATE
operations for a single owner andTRANSFER
operations between single entitiesLater
CREATE
operations for multiple owners andTRANSFER
between multiple entitiesThe text was updated successfully, but these errors were encountered: