mirror of
https://github.com/planetmint/planetmint.git
synced 2025-03-30 15:08:31 +00:00
renamed the flask connection pool (class name)
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
1766b2ddb9
commit
8d3e1fd725
@ -23,7 +23,6 @@ from transactions.types.elections.election import Election
|
||||
from transactions.types.elections.validator_utils import election_id_to_public_key
|
||||
|
||||
from planetmint.abci.tendermint_utils import (
|
||||
merkleroot,
|
||||
key_from_base64,
|
||||
public_key_to_base64,
|
||||
encode_validator,
|
||||
@ -39,7 +38,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Validator:
|
||||
def __init__(self):
|
||||
def __init__(self, async_io: bool = False):
|
||||
self.async_io = async_io
|
||||
self.models = Models()
|
||||
self.validation = Validator._get_validationmethod()
|
||||
|
||||
|
@ -81,7 +81,7 @@ def create_app(*, debug=False, threads=1, planetmint_factory=None):
|
||||
|
||||
app.debug = debug
|
||||
|
||||
app.config["validator_obj"] = utils.pool(planetmint_factory, size=threads)
|
||||
app.config["validator_class_name"] = utils.pool(planetmint_factory, size=threads)
|
||||
|
||||
add_routes(app)
|
||||
|
||||
|
@ -26,9 +26,9 @@ class AssetListApi(Resource):
|
||||
if not args["limit"]:
|
||||
del args["limit"]
|
||||
|
||||
pool = current_app.config["validator_obj"]
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
|
||||
with pool() as validator:
|
||||
with validator_class() as validator:
|
||||
assets = validator.models.get_assets_by_cid(cid, **args)
|
||||
|
||||
try:
|
||||
|
@ -20,9 +20,9 @@ class LatestBlock(Resource):
|
||||
A JSON string containing the data about the block.
|
||||
"""
|
||||
|
||||
pool = current_app.config["validator_obj"]
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
|
||||
with pool() as validator:
|
||||
with validator_class() as validator:
|
||||
block = validator.models.get_latest_block()
|
||||
|
||||
if not block:
|
||||
@ -42,9 +42,9 @@ class BlockApi(Resource):
|
||||
A JSON string containing the data about the block.
|
||||
"""
|
||||
|
||||
pool = current_app.config["validator_obj"]
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
|
||||
with pool() as validator:
|
||||
with validator_class() as validator:
|
||||
block = validator.models.get_block(block_id=block_id)
|
||||
|
||||
if not block:
|
||||
@ -68,9 +68,9 @@ class BlockListApi(Resource):
|
||||
args = parser.parse_args(strict=True)
|
||||
tx_id = args["transaction_id"]
|
||||
|
||||
pool = current_app.config["validator_obj"]
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
|
||||
with pool() as validator:
|
||||
with validator_class() as validator:
|
||||
block = validator.models.get_block_containing_tx(tx_id)
|
||||
|
||||
if not block:
|
||||
|
@ -34,9 +34,9 @@ class MetadataApi(Resource):
|
||||
if not args["limit"]:
|
||||
del args["limit"]
|
||||
|
||||
pool = current_app.config["validator_obj"]
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
|
||||
with pool() as validator:
|
||||
with validator_class() as validator:
|
||||
metadata = validator.models.get_metadata_by_cid(cid, **args)
|
||||
|
||||
try:
|
||||
|
@ -22,8 +22,8 @@ class OutputListApi(Resource):
|
||||
parser.add_argument("spent", type=parameters.valid_bool)
|
||||
args = parser.parse_args(strict=True)
|
||||
|
||||
pool = current_app.config["validator_obj"]
|
||||
with pool() as validator:
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
with validator_class() as validator:
|
||||
try:
|
||||
outputs = validator.models.get_outputs_filtered(args["public_key"], args["spent"])
|
||||
except Exception as e:
|
||||
|
@ -34,9 +34,9 @@ class TransactionApi(Resource):
|
||||
Return:
|
||||
A JSON string containing the data about the transaction.
|
||||
"""
|
||||
pool = current_app.config["validator_obj"]
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
|
||||
with pool() as validator:
|
||||
with validator_class() as validator:
|
||||
tx = validator.models.get_transaction(tx_id)
|
||||
|
||||
if not tx:
|
||||
@ -52,7 +52,7 @@ class TransactionListApi(Resource):
|
||||
parser.add_argument("asset_ids", type=parameters.valid_txid_list, required=True)
|
||||
parser.add_argument("last_tx", type=parameters.valid_bool, required=False)
|
||||
args = parser.parse_args()
|
||||
with current_app.config["validator_obj"]() as validator:
|
||||
with current_app.config["validator_class_name"]() as validator:
|
||||
txs = validator.models.get_transactions_filtered(**args)
|
||||
|
||||
return [tx.to_dict() for tx in txs]
|
||||
@ -68,7 +68,7 @@ class TransactionListApi(Resource):
|
||||
args = parser.parse_args()
|
||||
mode = str(args["mode"])
|
||||
|
||||
pool = current_app.config["validator_obj"]
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
|
||||
# `force` will try to format the body of the POST request even if the
|
||||
# `content-type` header is not set to `application/json`
|
||||
@ -87,9 +87,9 @@ class TransactionListApi(Resource):
|
||||
except Exception as e:
|
||||
return make_error(500, "Invalid transaction ({}): {} - {}".format(type(e).__name__, e, tx), level="error")
|
||||
|
||||
with pool() as planet:
|
||||
with validator_class() as validator:
|
||||
try:
|
||||
planet.validate_transaction(tx_obj)
|
||||
validator.validate_transaction(tx_obj)
|
||||
except ValidationError as e:
|
||||
return make_error(400, "Invalid transaction ({}): {}".format(type(e).__name__, e))
|
||||
except Exception as e:
|
||||
|
@ -15,9 +15,9 @@ class ValidatorsApi(Resource):
|
||||
A JSON string containing the validator set of the current node.
|
||||
"""
|
||||
|
||||
pool = current_app.config["validator_obj"]
|
||||
validator_class = current_app.config["validator_class_name"]
|
||||
|
||||
with pool() as validator:
|
||||
with validator_class() as validator:
|
||||
validators = validator.models.get_validators()
|
||||
|
||||
return validators
|
||||
|
Loading…
x
Reference in New Issue
Block a user