pixelspark / catena

Catena is a distributed database based on a blockchain, accessible using SQL.
MIT License
302 stars 23 forks source link

How to submit mutating queries programatically to catena? #136

Open grakshith opened 5 years ago

grakshith commented 5 years ago

Right now, the postgres wire protocol just supports non mutating queries. The HTTP API also does not support mutating queries. Is there any other way to submit mutating queries(transactions) so that they can be automated?

pixelspark commented 5 years ago

Both actually support submitting mutating queries!

When you use the pq protocol, just connect with your hashed public key as username and private key as password (the server will sign and submit any mutating query; note that this is not the optimal solution from a security point of view as the private key is transmitted unencrypted over a socket - nevertheless it should be okay for localhost communication). When you do not provide a (valid) key hash as username or omit the password, the server will indeed only allow immutable queries.

You can also use the HTTP API, although you'd have to build and sign the transaction yourself. The web client can show you how to do this (just create a mutating transaction there and observe the requests made).