mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 14:35:45 +00:00
removed depricated code
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
0286ecc163
commit
020c9724d1
@ -25,6 +25,10 @@ For reference, the possible headings are:
|
|||||||
* **Known Issues**
|
* **Known Issues**
|
||||||
* **Notes**
|
* **Notes**
|
||||||
|
|
||||||
|
## [2.0.0] - 2023-12-01
|
||||||
|
* **Changed** changed tarantool db schema
|
||||||
|
* **Removed** removed text_search routes
|
||||||
|
* **Added** metadata / asset cid route for fetching transactions
|
||||||
|
|
||||||
## [1.3.2] - 2022-28-11
|
## [1.3.2] - 2022-28-11
|
||||||
* **Changed** new zenroom 2.3.1 support
|
* **Changed** new zenroom 2.3.1 support
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import logging
|
|||||||
|
|
||||||
from functools import singledispatch
|
from functools import singledispatch
|
||||||
from planetmint.config import Config
|
from planetmint.config import Config
|
||||||
from planetmint.backend.connection import Connection
|
|
||||||
from transactions.common.exceptions import ValidationError
|
from transactions.common.exceptions import ValidationError
|
||||||
from transactions.common.utils import (
|
from transactions.common.utils import (
|
||||||
validate_all_values_for_key_in_obj,
|
validate_all_values_for_key_in_obj,
|
||||||
|
|||||||
@ -1,78 +0,0 @@
|
|||||||
box.cfg{listen = 3303}
|
|
||||||
|
|
||||||
function indexed_pattern_search(space_name, field_no, pattern)
|
|
||||||
if (box.space[space_name] == nil) then
|
|
||||||
print("Error: Failed to find the specified space")
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
local index_no = -1
|
|
||||||
for i=0,box.schema.INDEX_MAX,1 do
|
|
||||||
if (box.space[space_name].index[i] == nil) then break end
|
|
||||||
if (box.space[space_name].index[i].type == "TREE"
|
|
||||||
and box.space[space_name].index[i].parts[1].fieldno == field_no
|
|
||||||
and (box.space[space_name].index[i].parts[1].type == "scalar"
|
|
||||||
or box.space[space_name].index[i].parts[1].type == "string")) then
|
|
||||||
index_no = i
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (index_no == -1) then
|
|
||||||
print("Error: Failed to find an appropriate index")
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
local index_search_key = ""
|
|
||||||
local index_search_key_length = 0
|
|
||||||
local last_character = ""
|
|
||||||
local c = ""
|
|
||||||
local c2 = ""
|
|
||||||
for i=1,string.len(pattern),1 do
|
|
||||||
c = string.sub(pattern, i, i)
|
|
||||||
if (last_character ~= "%") then
|
|
||||||
if (c == '^' or c == "$" or c == "(" or c == ")" or c == "."
|
|
||||||
or c == "[" or c == "]" or c == "*" or c == "+"
|
|
||||||
or c == "-" or c == "?") then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
if (c == "%") then
|
|
||||||
c2 = string.sub(pattern, i + 1, i + 1)
|
|
||||||
if (string.match(c2, "%p") == nil) then break end
|
|
||||||
index_search_key = index_search_key .. c2
|
|
||||||
else
|
|
||||||
index_search_key = index_search_key .. c
|
|
||||||
end
|
|
||||||
end
|
|
||||||
last_character = c
|
|
||||||
end
|
|
||||||
index_search_key_length = string.len(index_search_key)
|
|
||||||
local result_set = {}
|
|
||||||
local number_of_tuples_in_result_set = 0
|
|
||||||
local previous_tuple_field = ""
|
|
||||||
while true do
|
|
||||||
local number_of_tuples_since_last_yield = 0
|
|
||||||
local is_time_for_a_yield = false
|
|
||||||
for _,tuple in box.space[space_name].index[index_no]:
|
|
||||||
pairs(index_search_key,{iterator = box.index.GE}) do
|
|
||||||
if (string.sub(tuple[field_no], 1, index_search_key_length)
|
|
||||||
> index_search_key) then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
number_of_tuples_since_last_yield = number_of_tuples_since_last_yield + 1
|
|
||||||
if (number_of_tuples_since_last_yield >= 10
|
|
||||||
and tuple[field_no] ~= previous_tuple_field) then
|
|
||||||
index_search_key = tuple[field_no]
|
|
||||||
is_time_for_a_yield = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
previous_tuple_field = tuple[field_no]
|
|
||||||
if (string.match(tuple[field_no], pattern) ~= nil) then
|
|
||||||
number_of_tuples_in_result_set = number_of_tuples_in_result_set + 1
|
|
||||||
result_set[number_of_tuples_in_result_set] = tuple
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (is_time_for_a_yield ~= true) then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
require('fiber').yield()
|
|
||||||
end
|
|
||||||
return result_set
|
|
||||||
end
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
box.space.abci_chains:drop()
|
|
||||||
box.space.blocks:drop()
|
|
||||||
box.space.elections:drop()
|
|
||||||
box.space.pre_commits:drop()
|
|
||||||
box.space.utxos:drop()
|
|
||||||
box.space.validators:drop()
|
|
||||||
box.space.transactions:drop()
|
|
||||||
box.space.outputs:drop()
|
|
||||||
@ -8,142 +8,6 @@ from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
register_schema = module_dispatch_registrar(backend.schema)
|
register_schema = module_dispatch_registrar(backend.schema)
|
||||||
|
|
||||||
SPACE_NAMES = (
|
|
||||||
"abci_chains",
|
|
||||||
"assets",
|
|
||||||
"blocks",
|
|
||||||
"blocks_tx",
|
|
||||||
"elections",
|
|
||||||
"meta_data",
|
|
||||||
"pre_commits",
|
|
||||||
"validators",
|
|
||||||
"transactions",
|
|
||||||
"inputs",
|
|
||||||
"outputs",
|
|
||||||
"keys",
|
|
||||||
"utxos",
|
|
||||||
"scripts",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
SPACE_COMMANDS = {
|
|
||||||
"abci_chains": "abci_chains = box.schema.space.create('abci_chains', {engine='memtx', is_sync = false})",
|
|
||||||
"assets": "assets = box.schema.space.create('assets' , {engine='memtx' , is_sync=false})",
|
|
||||||
"blocks": "blocks = box.schema.space.create('blocks' , {engine='memtx' , is_sync=false})",
|
|
||||||
"blocks_tx": "blocks_tx = box.schema.space.create('blocks_tx')",
|
|
||||||
"elections": "elections = box.schema.space.create('elections',{engine = 'memtx' , is_sync = false})",
|
|
||||||
"meta_data": "meta_datas = box.schema.space.create('meta_data',{engine = 'memtx' , is_sync = false})",
|
|
||||||
"pre_commits": "pre_commits = box.schema.space.create('pre_commits' , {engine='memtx' , is_sync=false})",
|
|
||||||
"validators": "validators = box.schema.space.create('validators' , {engine = 'memtx' , is_sync = false})",
|
|
||||||
"transactions": "transactions = box.schema.space.create('transactions',{engine='memtx' , is_sync=false})",
|
|
||||||
"inputs": "inputs = box.schema.space.create('inputs')",
|
|
||||||
"outputs": "outputs = box.schema.space.create('outputs')",
|
|
||||||
"keys": "keys = box.schema.space.create('keys')",
|
|
||||||
"utxos": "utxos = box.schema.space.create('utxos', {engine = 'memtx' , is_sync = false})",
|
|
||||||
"scripts": "scripts = box.schema.space.create('scripts', {engine = 'memtx' , is_sync = false})",
|
|
||||||
}
|
|
||||||
|
|
||||||
INDEX_COMMANDS = {
|
|
||||||
"abci_chains": {
|
|
||||||
"id_search": "abci_chains:create_index('id_search' ,{type='tree', parts={'id'}})",
|
|
||||||
"height_search": "abci_chains:create_index('height_search' ,{type='tree', unique=false, parts={'height'}})",
|
|
||||||
},
|
|
||||||
"assets": {
|
|
||||||
"txid_search": "assets:create_index('txid_search', {type='tree', parts={'tx_id'}})",
|
|
||||||
"assetid_search": "assets:create_index('assetid_search', {type='tree',unique=false, parts={'asset_id', 'tx_id'}})", # noqa: E501
|
|
||||||
"only_asset_search": "assets:create_index('only_asset_search', {type='tree', unique=false, parts={'asset_id'}})", # noqa: E501
|
|
||||||
"text_search": "assets:create_index('secondary', {unique=false,parts={1,'string'}})",
|
|
||||||
},
|
|
||||||
"blocks": {
|
|
||||||
"id_search": "blocks:create_index('id_search' , {type='tree' , parts={'block_id'}})",
|
|
||||||
"block_search": "blocks:create_index('block_search' , {type='tree', unique = false, parts={'height'}})",
|
|
||||||
"block_id_search": "blocks:create_index('block_id_search', {type = 'hash', parts ={'block_id'}})",
|
|
||||||
},
|
|
||||||
"blocks_tx": {
|
|
||||||
"id_search": "blocks_tx:create_index('id_search',{ type = 'tree', parts={'transaction_id'}})",
|
|
||||||
"block_search": "blocks_tx:create_index('block_search', {type = 'tree',unique=false, parts={'block_id'}})",
|
|
||||||
},
|
|
||||||
"elections": {
|
|
||||||
"id_search": "elections:create_index('id_search' , {type='tree', parts={'election_id'}})",
|
|
||||||
"height_search": "elections:create_index('height_search' , {type='tree',unique=false, parts={'height'}})",
|
|
||||||
"update_search": "elections:create_index('update_search', {type='tree', unique=false, parts={'election_id', 'height'}})", # noqa: E501
|
|
||||||
},
|
|
||||||
"meta_data": {
|
|
||||||
"id_search": "meta_datas:create_index('id_search', { type='tree' , parts={'transaction_id'}})",
|
|
||||||
"text_search": "meta_datas:create_index('secondary', {unique=false,parts={2,'string'}})",
|
|
||||||
},
|
|
||||||
"pre_commits": {
|
|
||||||
"id_search": "pre_commits:create_index('id_search', {type ='tree' , parts={'commit_id'}})",
|
|
||||||
"height_search": "pre_commits:create_index('height_search', {type ='tree',unique=true, parts={'height'}})",
|
|
||||||
},
|
|
||||||
"validators": {
|
|
||||||
"id_search": "validators:create_index('id_search' , {type='tree' , parts={'validator_id'}})",
|
|
||||||
"height_search": "validators:create_index('height_search' , {type='tree', unique=true, parts={'height'}})",
|
|
||||||
},
|
|
||||||
"transactions": {
|
|
||||||
"id_search": "transactions:create_index('id_search' , {type = 'tree' , parts={'transaction_id'}})",
|
|
||||||
"transaction_search": "transactions:create_index('transaction_search' , {type = 'tree',unique=false, parts={'operation', 'transaction_id'}})", # noqa: E501
|
|
||||||
},
|
|
||||||
"inputs": {
|
|
||||||
"delete_search": "inputs:create_index('delete_search' , {type = 'tree', parts={'input_id'}})",
|
|
||||||
"spent_search": "inputs:create_index('spent_search' , {type = 'tree', unique=false, parts={'fulfills_transaction_id', 'fulfills_output_index'}})", # noqa: E501
|
|
||||||
"id_search": "inputs:create_index('id_search', {type = 'tree', unique=false, parts = {'transaction_id'}})",
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"unique_search": "outputs:create_index('unique_search' ,{type='tree', parts={'output_id'}})",
|
|
||||||
"id_search": "outputs:create_index('id_search' ,{type='tree', unique=false, parts={'transaction_id'}})",
|
|
||||||
},
|
|
||||||
"keys": {
|
|
||||||
"id_search": "keys:create_index('id_search', {type = 'tree', parts={'id'}})",
|
|
||||||
"keys_search": "keys:create_index('keys_search', {type = 'tree', unique=false, parts={'public_key'}})",
|
|
||||||
"txid_search": "keys:create_index('txid_search', {type = 'tree', unique=false, parts={'transaction_id'}})",
|
|
||||||
"output_search": "keys:create_index('output_search', {type = 'tree', unique=false, parts={'output_id'}})",
|
|
||||||
},
|
|
||||||
"utxos": {
|
|
||||||
"id_search": "utxos:create_index('id_search', {type='tree' , parts={'transaction_id', 'output_index'}})",
|
|
||||||
"transaction_search": "utxos:create_index('transaction_search', {type='tree', unique=false, parts={'transaction_id'}})", # noqa: E501
|
|
||||||
"index_Search": "utxos:create_index('index_search', {type='tree', unique=false, parts={'output_index'}})",
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"txid_search": "scripts:create_index('txid_search', {type='tree', parts={'transaction_id'}})",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SCHEMA_COMMANDS = {
|
|
||||||
"abci_chains": "abci_chains:format({{name='height' , type='integer'},{name='is_synched' , type='boolean'},{name='chain_id',type='string'}, {name='id', type='string'}})", # noqa: E501
|
|
||||||
"assets": "assets:format({{name='data' , type='string'}, {name='tx_id', type='string'}, {name='asset_id', type='string'}})", # noqa: E501
|
|
||||||
"blocks": "blocks:format{{name='app_hash',type='string'},{name='height' , type='integer'},{name='block_id' , type='string'}}", # noqa: E501
|
|
||||||
"blocks_tx": "blocks_tx:format{{name='transaction_id', type = 'string'}, {name = 'block_id', type = 'string'}}",
|
|
||||||
"elections": "elections:format({{name='election_id' , type='string'},{name='height' , type='integer'}, {name='is_concluded' , type='boolean'}})", # noqa: E501
|
|
||||||
"meta_data": "meta_datas:format({{name='transaction_id' , type='string'}, {name='meta_data' , type='string'}})", # noqa: E501
|
|
||||||
"pre_commits": "pre_commits:format({{name='commit_id', type='string'}, {name='height',type='integer'}, {name='transactions',type=any}})", # noqa: E501
|
|
||||||
"validators": "validators:format({{name='validator_id' , type='string'},{name='height',type='integer'},{name='validators' , type='any'}})", # noqa: E501
|
|
||||||
"transactions": "transactions:format({{name='transaction_id' , type='string'}, {name='operation' , type='string'}, {name='version' ,type='string'}, {name='dict_map', type='any'}})", # noqa: E501
|
|
||||||
"inputs": "inputs:format({{name='transaction_id' , type='string'}, {name='fulfillment' , type='any'}, {name='owners_before' , type='array'}, {name='fulfills_transaction_id', type = 'string'}, {name='fulfills_output_index', type = 'string'}, {name='input_id', type='string'}, {name='input_index', type='number'}})", # noqa: E501
|
|
||||||
"outputs": "outputs:format({{name='transaction_id' , type='string'}, {name='amount' , type='string'}, {name='uri', type='string'}, {name='details_type', type='string'}, {name='details_public_key', type='any'}, {name = 'output_id', type = 'string'}, {name='treshold', type='any'}, {name='subconditions', type='any'}, {name='output_index', type='number'}})", # noqa: E501
|
|
||||||
"keys": "keys:format({{name = 'id', type='string'}, {name = 'transaction_id', type = 'string'} ,{name = 'output_id', type = 'string'}, {name = 'public_key', type = 'string'}, {name = 'key_index', type = 'integer'}})", # noqa: E501
|
|
||||||
"utxos": "utxos:format({{name='transaction_id' , type='string'}, {name='output_index' , type='integer'}, {name='utxo_dict', type='string'}})", # noqa: E501
|
|
||||||
"scripts": "scripts:format({{name='transaction_id', type='string'},{name='script' , type='any'}})", # noqa: E501
|
|
||||||
}
|
|
||||||
|
|
||||||
SCHEMA_DROP_COMMANDS = {
|
|
||||||
"abci_chains": "box.space.abci_chains:drop()",
|
|
||||||
"assets": "box.space.assets:drop()",
|
|
||||||
"blocks": "box.space.blocks:drop()",
|
|
||||||
"blocks_tx": "box.space.blocks_tx:drop()",
|
|
||||||
"elections": "box.space.elections:drop()",
|
|
||||||
"meta_data": "box.space.meta_data:drop()",
|
|
||||||
"pre_commits": "box.space.pre_commits:drop()",
|
|
||||||
"validators": "box.space.validators:drop()",
|
|
||||||
"transactions": "box.space.transactions:drop()",
|
|
||||||
"inputs": "box.space.inputs:drop()",
|
|
||||||
"outputs": "box.space.outputs:drop()",
|
|
||||||
"keys": "box.space.keys:drop()",
|
|
||||||
"utxos": "box.space.utxos:drop()",
|
|
||||||
"scripts": "box.space.scripts:drop()",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@register_schema(TarantoolDBConnection)
|
@register_schema(TarantoolDBConnection)
|
||||||
def init_database(connection, db_name=None):
|
def init_database(connection, db_name=None):
|
||||||
|
|||||||
@ -3,8 +3,6 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
|
||||||
|
|
||||||
|
|
||||||
def _check_spaces_by_list(conn, space_names):
|
def _check_spaces_by_list(conn, space_names):
|
||||||
_exists = []
|
_exists = []
|
||||||
|
|||||||
@ -27,7 +27,6 @@ from transactions.common.transaction_mode_types import BROADCAST_TX_COMMIT
|
|||||||
from planetmint.tendermint_utils import key_from_base64
|
from planetmint.tendermint_utils import key_from_base64
|
||||||
from planetmint.backend import schema, query
|
from planetmint.backend import schema, query
|
||||||
from transactions.common.crypto import key_pair_from_ed25519_key, public_key_from_ed25519_key
|
from transactions.common.crypto import key_pair_from_ed25519_key, public_key_from_ed25519_key
|
||||||
from transactions.common.exceptions import DatabaseDoesNotExist
|
|
||||||
from planetmint.lib import Block
|
from planetmint.lib import Block
|
||||||
from tests.utils import gen_vote
|
from tests.utils import gen_vote
|
||||||
from planetmint.config import Config
|
from planetmint.config import Config
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import random
|
|||||||
from functools import singledispatch
|
from functools import singledispatch
|
||||||
from planetmint.backend.localmongodb.connection import LocalMongoDBConnection
|
from planetmint.backend.localmongodb.connection import LocalMongoDBConnection
|
||||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||||
from planetmint.backend.schema import TABLES, SPACE_NAMES
|
from planetmint.backend.schema import TABLES
|
||||||
from transactions.common import crypto
|
from transactions.common import crypto
|
||||||
from transactions.common.transaction_mode_types import BROADCAST_TX_COMMIT
|
from transactions.common.transaction_mode_types import BROADCAST_TX_COMMIT
|
||||||
from transactions.types.assets.create import Create
|
from transactions.types.assets.create import Create
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user