kevacoin-project / kevacoin

Kevacoin source tree
https://www.kevacoin.org
MIT License
32 stars 16 forks source link

Allow the use of namespace display name in keva operations #12

Open kevacoin-project opened 4 years ago

kevacoin-project commented 4 years ago

Current keva operations (e.g keva_put, keva_get, keva_delete, keva_filter) need the actual namespace Id (prefix 'N'). It would be more convenient if we can simply use the internal display name.

E.g. instead of:

kevacoin-cli keva_namespace test5

{
  "txid": "1b79f58f278e731ba59484c53fc65c472ee1373a7bc559c907336c860c53b36a",
  "namespaceId": "NL5VgsZcmyHANsLjsdvhP8roctBEKC55Nv"
}

kevacoin-cli keva_put NL5VgsZcmyHANsLjsdvhP8roctBEKC55Nv first_key first_value

It can be simplied as:

kevacoin-cli keva_namespace test5
kevacoin-cli keva_put 'test5' first_key first_value

Internally, it searches the namespace with the display name "test5", and find out the namespace Id, and uses the namespace Id for the operation.

Remember that the display name is not unique, which means two namespaces can have the same display name. In this case, maybe we can decline the operation and ask for actual namespace Id.

kawww commented 4 years ago

I have another idea: add "keva_num block count" to get namespaceid, key and value.

Number is easy to remember and talk. Number is also unique.

I use these command to get data.

` keva_filter NY36kGYydqRrCtZrKryegKQbecs4JBq7qq ONEONE

[ { "key": "ONEONE", "value": "OKOKgogogogogogogNY36kGYydqRrCtZrKryegKQbecs4JBq7qq", "txid": "ddbb47c78264d06bc5a2790d15610b7bdce9653aaf20874af29611b1fe4abacc", "vout": 1, "address": "VF4AZ3T4eWfEVmoWSCEJmVMqMGahcL1GLK", "height": 29224 } ] `

` getblockhash 29224

b375836dd625e26d77a6713a6f2d426fd3d6f9d4781e308c872a714b659713be `

` getblock b375836dd625e26d77a6713a6f2d426fd3d6f9d4781e308c872a714b659713be

{ "hash": "b375836dd625e26d77a6713a6f2d426fd3d6f9d4781e308c872a714b659713be", "confirmations": 4446, "strippedsize": 1257, "size": 1726, "weight": 5497, "height": 29224, "version": 536870912, "versionHex": "20000000", "merkleroot": "5f0462e42d4429360806004815281f271f64220e9dfed10572144aefb93a0952", "tx": [ "ab2d2fd5de674d467ba8c87ce016fecbf963644a987597cfa73a45e671709c44", "ddbb47c78264d06bc5a2790d15610b7bdce9653aaf20874af29611b1fe4abacc", "10eb71a9792a7e4ea4598ed0f4c3505987a92f296477de44e872753df9eb0f8f" ], "time": 1583057655, "mediantime": 1583057009, "nonce": 1426088432, "bits": "1d0a6597", "difficulty": 413097026.6293495, "chainwork": "000000000000000000000000000000000000000000000000000006d189195507", "nTx": 3, "previousblockhash": "994abe4f6dafe8b3d23375a32c74a650a95610cce5f983596f4de0a2b95467df", "nextblockhash": "f224c441e7e0032fb9d7e58e6f82630e42535c91cfcdca83a90822aa1539c800" } `

So we get these txid, we get key and value:

keva_num 29224 1 => ab2d2fd5de674d467ba8c87ce016fecbf963644a987597cfa73a45e671709c44 null keva_num 29224 2 =>ddbb47c78264d06bc5a2790d15610b7bdce9653aaf20874af29611b1fe4abacc namespaceid...key...value keva_num 29224 2 =>10eb71a9792a7e4ea4598ed0f4c3505987a92f296477de44e872753df9eb0f8f namespaceid...key...value

keva_num 29224

txid1 null txid2 namespaceid...key...value txid3 namespaceid...key...value

example: http://galaxyos.io/subscription.php?block=29224

I use size to select the different txid.

http://galaxyos.io/subscription.php?block=29224&sub=503

http://galaxyos.io/subscription.php?block=29224&sub=895

Then every txid, namespaceid, key and value have a number for getting namespaceid, key and value.

29224 29224 503 29224 895