2020-04-06 11:52:18 +02:00
|
|
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
|
|
|
# BigchainDB and IPDB software contributors.
|
2018-08-16 12:31:32 +02:00
|
|
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
|
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
|
2016-02-10 19:55:33 +01:00
|
|
|
import copy
|
2017-04-18 14:51:12 +02:00
|
|
|
import logging
|
2016-02-10 19:55:33 +01:00
|
|
|
|
2018-06-11 13:08:03 +02:00
|
|
|
from bigchaindb.log import DEFAULT_LOGGING_CONFIG as log_config
|
Refactor tendermint directory to project root (#2401)
* Problem: core.py contains an unused class, `Bigchain`
Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.
* Problem: core.py contains an unused class, `Bigchain`
Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.
* Fixed flake8 complaint about too many blank lines
* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...
Sorry in advance!
* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...
Sorry in advance!
* Updating from master changed BigchainDB.process_post_response to a private method, so I had to align with that.
* Fixed a couple stale references to bigchaindb.Bigchain in docstrings
* Missed a reference to `Bigchain` in a patch call...
* Problem: BigchainDB class should be part of project root
Solution: Removed the /tendermint directory and moved its contents to project root
* Problem: Flake8 complained that imports were not at the top of the file
Solution: Had to play around with the order of imports to avoid cyclic dependencies, but its working and style compliant now
* Problem: Stale reference to /tendermint directory in the index
Solution: Removed the references to /tendermint
* Problem: Flake8 complaining of unused import in __init__.py
Solution: The import is there so I can import App directly from bigchaindb, rather than from bigchaindb.core (which I think improves code readability. I added a # noqa to silence Flake8.
* Problem: Stale references to `bigchaindb.tendermint.BigchainDB` in the rst files cause Sphinx to fail
Solution: Updated the autodoc files to use `bigchaindb.BigchainDB` instead
* Problem: Stale reference to the `tendermint` directory in an @patch in a disabled test
Solution: Updated the @patch for completeness
* Problem: BigchainDB class should be part of project root
Solution: Removed the /tendermint directory and moved its contents to project root
* Problem: Flake8 complained that imports were not at the top of the file
Solution: Had to play around with the order of imports to avoid cyclic dependencies, but its working and style compliant now
* Problem: Stale reference to /tendermint directory in the index
Solution: Removed the references to /tendermint
* Problem: Flake8 complaining of unused import in __init__.py
Solution: The import is there so I can import App directly from bigchaindb, rather than from bigchaindb.core (which I think improves code readability. I added a # noqa to silence Flake8.
* Problem: Stale references to `bigchaindb.tendermint.BigchainDB` in the rst files cause Sphinx to fail
Solution: Updated the autodoc files to use `bigchaindb.BigchainDB` instead
* Problem: Stale reference to the `tendermint` directory in an @patch in a disabled test
Solution: Updated the @patch for completeness
2018-07-25 16:59:25 +02:00
|
|
|
from bigchaindb.lib import BigchainDB # noqa
|
2018-09-17 13:59:57 +02:00
|
|
|
from bigchaindb.migrations.chain_migration_election import ChainMigrationElection
|
Refactor tendermint directory to project root (#2401)
* Problem: core.py contains an unused class, `Bigchain`
Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.
* Problem: core.py contains an unused class, `Bigchain`
Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.
* Fixed flake8 complaint about too many blank lines
* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...
Sorry in advance!
* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...
Sorry in advance!
* Updating from master changed BigchainDB.process_post_response to a private method, so I had to align with that.
* Fixed a couple stale references to bigchaindb.Bigchain in docstrings
* Missed a reference to `Bigchain` in a patch call...
* Problem: BigchainDB class should be part of project root
Solution: Removed the /tendermint directory and moved its contents to project root
* Problem: Flake8 complained that imports were not at the top of the file
Solution: Had to play around with the order of imports to avoid cyclic dependencies, but its working and style compliant now
* Problem: Stale reference to /tendermint directory in the index
Solution: Removed the references to /tendermint
* Problem: Flake8 complaining of unused import in __init__.py
Solution: The import is there so I can import App directly from bigchaindb, rather than from bigchaindb.core (which I think improves code readability. I added a # noqa to silence Flake8.
* Problem: Stale references to `bigchaindb.tendermint.BigchainDB` in the rst files cause Sphinx to fail
Solution: Updated the autodoc files to use `bigchaindb.BigchainDB` instead
* Problem: Stale reference to the `tendermint` directory in an @patch in a disabled test
Solution: Updated the @patch for completeness
* Problem: BigchainDB class should be part of project root
Solution: Removed the /tendermint directory and moved its contents to project root
* Problem: Flake8 complained that imports were not at the top of the file
Solution: Had to play around with the order of imports to avoid cyclic dependencies, but its working and style compliant now
* Problem: Stale reference to /tendermint directory in the index
Solution: Removed the references to /tendermint
* Problem: Flake8 complaining of unused import in __init__.py
Solution: The import is there so I can import App directly from bigchaindb, rather than from bigchaindb.core (which I think improves code readability. I added a # noqa to silence Flake8.
* Problem: Stale references to `bigchaindb.tendermint.BigchainDB` in the rst files cause Sphinx to fail
Solution: Updated the autodoc files to use `bigchaindb.BigchainDB` instead
* Problem: Stale reference to the `tendermint` directory in an @patch in a disabled test
Solution: Updated the @patch for completeness
2018-07-25 16:59:25 +02:00
|
|
|
from bigchaindb.version import __version__ # noqa
|
|
|
|
from bigchaindb.core import App # noqa
|
2017-04-18 14:51:12 +02:00
|
|
|
|
2016-04-07 14:15:29 +02:00
|
|
|
# from functools import reduce
|
|
|
|
# PORT_NUMBER = reduce(lambda x, y: x * y, map(ord, 'BigchainDB')) % 2**16
|
|
|
|
# basically, the port number is 9984
|
|
|
|
|
2017-03-28 14:51:02 +02:00
|
|
|
# The following variable is used by `bigchaindb configure` to
|
|
|
|
# prompt the user for database values. We cannot rely on
|
2018-06-08 15:50:50 +02:00
|
|
|
# _base_database_localmongodb.keys() because dicts are unordered.
|
|
|
|
# I tried to configure
|
2017-03-28 14:51:02 +02:00
|
|
|
|
2017-04-04 18:58:34 +02:00
|
|
|
_database_keys_map = {
|
2017-11-10 17:53:57 +01:00
|
|
|
'localmongodb': ('host', 'port', 'name'),
|
2017-04-04 18:58:34 +02:00
|
|
|
}
|
2017-03-28 14:51:02 +02:00
|
|
|
|
2017-11-10 17:53:57 +01:00
|
|
|
_base_database_localmongodb = {
|
2018-02-14 10:22:10 +01:00
|
|
|
'host': 'localhost',
|
|
|
|
'port': 27017,
|
|
|
|
'name': 'bigchain',
|
|
|
|
'replicaset': None,
|
|
|
|
'login': None,
|
|
|
|
'password': None,
|
2017-11-10 17:53:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_database_localmongodb = {
|
2018-02-14 10:22:10 +01:00
|
|
|
'backend': 'localmongodb',
|
2017-11-10 17:53:57 +01:00
|
|
|
'connection_timeout': 5000,
|
|
|
|
'max_tries': 3,
|
2018-02-14 10:22:10 +01:00
|
|
|
'ssl': False,
|
|
|
|
'ca_cert': None,
|
|
|
|
'certfile': None,
|
|
|
|
'keyfile': None,
|
|
|
|
'keyfile_passphrase': None,
|
|
|
|
'crlfile': None,
|
2017-11-10 17:53:57 +01:00
|
|
|
}
|
|
|
|
_database_localmongodb.update(_base_database_localmongodb)
|
|
|
|
|
2017-01-31 10:34:45 +01:00
|
|
|
_database_map = {
|
2017-11-10 17:53:57 +01:00
|
|
|
'localmongodb': _database_localmongodb,
|
2017-01-31 10:34:45 +01:00
|
|
|
}
|
|
|
|
|
2016-02-10 19:55:33 +01:00
|
|
|
config = {
|
2016-03-22 18:42:50 +01:00
|
|
|
'server': {
|
2016-04-07 14:15:29 +02:00
|
|
|
# Note: this section supports all the Gunicorn settings:
|
|
|
|
# - http://docs.gunicorn.org/en/stable/settings.html
|
2018-02-14 10:22:10 +01:00
|
|
|
'bind': 'localhost:9984',
|
2017-04-18 14:57:11 +02:00
|
|
|
'loglevel': logging.getLevelName(
|
|
|
|
log_config['handlers']['console']['level']).lower(),
|
2018-05-03 11:52:54 +02:00
|
|
|
'workers': None, # if None, the value will be cpu_count * 2 + 1
|
2016-03-22 18:42:50 +01:00
|
|
|
},
|
2017-04-07 10:51:00 +02:00
|
|
|
'wsserver': {
|
2018-02-14 10:22:10 +01:00
|
|
|
'scheme': 'ws',
|
|
|
|
'host': 'localhost',
|
|
|
|
'port': 9985,
|
|
|
|
'advertised_scheme': 'ws',
|
|
|
|
'advertised_host': 'localhost',
|
|
|
|
'advertised_port': 9985,
|
2017-04-07 10:51:00 +02:00
|
|
|
},
|
2018-06-29 15:45:22 +02:00
|
|
|
'tendermint': {
|
|
|
|
'host': 'localhost',
|
2018-07-10 14:16:02 +02:00
|
|
|
'port': 26657,
|
2020-01-23 23:17:27 +01:00
|
|
|
'version': 'v0.31.5', # look for __tm_supported_versions__
|
2018-06-29 15:45:22 +02:00
|
|
|
},
|
2018-02-14 15:30:21 +01:00
|
|
|
# FIXME: hardcoding to localmongodb for now
|
2018-02-14 10:22:10 +01:00
|
|
|
'database': _database_map['localmongodb'],
|
2017-03-13 17:55:11 +01:00
|
|
|
'log': {
|
2017-04-18 14:51:12 +02:00
|
|
|
'file': log_config['handlers']['file']['filename'],
|
|
|
|
'error_file': log_config['handlers']['errors']['filename'],
|
|
|
|
'level_console': logging.getLevelName(
|
2017-04-18 15:58:14 +02:00
|
|
|
log_config['handlers']['console']['level']).lower(),
|
2017-04-18 14:51:12 +02:00
|
|
|
'level_logfile': logging.getLevelName(
|
2017-04-18 15:58:14 +02:00
|
|
|
log_config['handlers']['file']['level']).lower(),
|
2017-04-18 14:51:12 +02:00
|
|
|
'datefmt_console': log_config['formatters']['console']['datefmt'],
|
|
|
|
'datefmt_logfile': log_config['formatters']['file']['datefmt'],
|
|
|
|
'fmt_console': log_config['formatters']['console']['format'],
|
|
|
|
'fmt_logfile': log_config['formatters']['file']['format'],
|
2017-04-18 14:57:11 +02:00
|
|
|
'granular_levels': {},
|
2017-03-13 17:55:11 +01:00
|
|
|
},
|
2016-02-10 19:55:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# We need to maintain a backup copy of the original config dict in case
|
|
|
|
# the user wants to reconfigure the node. Check ``bigchaindb.config_utils``
|
|
|
|
# for more info.
|
|
|
|
_config = copy.deepcopy(config)
|
2018-07-27 17:38:24 +02:00
|
|
|
from bigchaindb.common.transaction import Transaction # noqa
|
|
|
|
from bigchaindb import models # noqa
|
|
|
|
from bigchaindb.upsert_validator import ValidatorElection # noqa
|
2018-09-11 15:39:46 +02:00
|
|
|
from bigchaindb.elections.vote import Vote # noqa
|
2018-07-27 17:38:24 +02:00
|
|
|
|
|
|
|
Transaction.register_type(Transaction.CREATE, models.Transaction)
|
|
|
|
Transaction.register_type(Transaction.TRANSFER, models.Transaction)
|
2018-09-11 15:39:46 +02:00
|
|
|
Transaction.register_type(ValidatorElection.OPERATION, ValidatorElection)
|
2018-09-17 13:59:57 +02:00
|
|
|
Transaction.register_type(ChainMigrationElection.OPERATION, ChainMigrationElection)
|
2018-09-11 15:39:46 +02:00
|
|
|
Transaction.register_type(Vote.OPERATION, Vote)
|