renamed bigchain_pool -> validator_obj

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2023-02-27 17:27:38 +01:00
parent 2c0b0f03c9
commit 1766b2ddb9
No known key found for this signature in database
7 changed files with 14 additions and 16 deletions

View File

@ -81,7 +81,7 @@ def create_app(*, debug=False, threads=1, planetmint_factory=None):
app.debug = debug app.debug = debug
app.config["bigchain_pool"] = utils.pool(planetmint_factory, size=threads) app.config["validator_obj"] = utils.pool(planetmint_factory, size=threads)
add_routes(app) add_routes(app)

View File

@ -26,7 +26,7 @@ class AssetListApi(Resource):
if not args["limit"]: if not args["limit"]:
del args["limit"] del args["limit"]
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
with pool() as validator: with pool() as validator:
assets = validator.models.get_assets_by_cid(cid, **args) assets = validator.models.get_assets_by_cid(cid, **args)

View File

@ -20,7 +20,7 @@ class LatestBlock(Resource):
A JSON string containing the data about the block. A JSON string containing the data about the block.
""" """
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
with pool() as validator: with pool() as validator:
block = validator.models.get_latest_block() block = validator.models.get_latest_block()
@ -42,7 +42,7 @@ class BlockApi(Resource):
A JSON string containing the data about the block. A JSON string containing the data about the block.
""" """
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
with pool() as validator: with pool() as validator:
block = validator.models.get_block(block_id=block_id) block = validator.models.get_block(block_id=block_id)
@ -68,7 +68,7 @@ class BlockListApi(Resource):
args = parser.parse_args(strict=True) args = parser.parse_args(strict=True)
tx_id = args["transaction_id"] tx_id = args["transaction_id"]
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
with pool() as validator: with pool() as validator:
block = validator.models.get_block_containing_tx(tx_id) block = validator.models.get_block_containing_tx(tx_id)

View File

@ -34,7 +34,7 @@ class MetadataApi(Resource):
if not args["limit"]: if not args["limit"]:
del args["limit"] del args["limit"]
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
with pool() as validator: with pool() as validator:
metadata = validator.models.get_metadata_by_cid(cid, **args) metadata = validator.models.get_metadata_by_cid(cid, **args)

View File

@ -22,7 +22,7 @@ class OutputListApi(Resource):
parser.add_argument("spent", type=parameters.valid_bool) parser.add_argument("spent", type=parameters.valid_bool)
args = parser.parse_args(strict=True) args = parser.parse_args(strict=True)
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
with pool() as validator: with pool() as validator:
try: try:
outputs = validator.models.get_outputs_filtered(args["public_key"], args["spent"]) outputs = validator.models.get_outputs_filtered(args["public_key"], args["spent"])

View File

@ -11,17 +11,15 @@ import logging
from flask import current_app, request, jsonify from flask import current_app, request, jsonify
from flask_restful import Resource, reqparse from flask_restful import Resource, reqparse
from transactions.common.transaction import Transaction
from transactions.common.transaction_mode_types import BROADCAST_TX_ASYNC from transactions.common.transaction_mode_types import BROADCAST_TX_ASYNC
from transactions.common.exceptions import ( from transactions.common.exceptions import (
SchemaValidationError, SchemaValidationError,
ValidationError, ValidationError,
) )
from planetmint.abci.rpc import ABCI_RPC, MODE_COMMIT, MODE_LIST
from planetmint.abci.rpc import ABCI_RPC
from planetmint.web.views.base import make_error
from planetmint.web.views import parameters from planetmint.web.views import parameters
from transactions.common.transaction import Transaction from planetmint.web.views.base import make_error
from planetmint.abci.rpc import MODE_COMMIT, MODE_LIST
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -36,7 +34,7 @@ class TransactionApi(Resource):
Return: Return:
A JSON string containing the data about the transaction. A JSON string containing the data about the transaction.
""" """
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
with pool() as validator: with pool() as validator:
tx = validator.models.get_transaction(tx_id) tx = validator.models.get_transaction(tx_id)
@ -54,7 +52,7 @@ class TransactionListApi(Resource):
parser.add_argument("asset_ids", type=parameters.valid_txid_list, required=True) parser.add_argument("asset_ids", type=parameters.valid_txid_list, required=True)
parser.add_argument("last_tx", type=parameters.valid_bool, required=False) parser.add_argument("last_tx", type=parameters.valid_bool, required=False)
args = parser.parse_args() args = parser.parse_args()
with current_app.config["bigchain_pool"]() as validator: with current_app.config["validator_obj"]() as validator:
txs = validator.models.get_transactions_filtered(**args) txs = validator.models.get_transactions_filtered(**args)
return [tx.to_dict() for tx in txs] return [tx.to_dict() for tx in txs]
@ -70,7 +68,7 @@ class TransactionListApi(Resource):
args = parser.parse_args() args = parser.parse_args()
mode = str(args["mode"]) mode = str(args["mode"])
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
# `force` will try to format the body of the POST request even if the # `force` will try to format the body of the POST request even if the
# `content-type` header is not set to `application/json` # `content-type` header is not set to `application/json`

View File

@ -15,7 +15,7 @@ class ValidatorsApi(Resource):
A JSON string containing the validator set of the current node. A JSON string containing the validator set of the current node.
""" """
pool = current_app.config["bigchain_pool"] pool = current_app.config["validator_obj"]
with pool() as validator: with pool() as validator:
validators = validator.models.get_validators() validators = validator.models.get_validators()