mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 04:42:36 -03:00
33b4d48cfc
Passing abstract Chain interface will let indexes run in separate processes. This commit does not change behavior in any way.
83 lines
2.8 KiB
Python
Executable file
83 lines
2.8 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
#
|
|
# Copyright (c) 2020-2022 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
#
|
|
# Check for circular dependencies
|
|
|
|
import os
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
|
|
EXPECTED_CIRCULAR_DEPENDENCIES = (
|
|
"chainparamsbase -> util/system -> chainparamsbase",
|
|
"node/blockstorage -> validation -> node/blockstorage",
|
|
"policy/fees -> txmempool -> policy/fees",
|
|
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel",
|
|
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel",
|
|
"qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog",
|
|
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel",
|
|
"wallet/fees -> wallet/wallet -> wallet/fees",
|
|
"wallet/wallet -> wallet/walletdb -> wallet/wallet",
|
|
"kernel/coinstats -> validation -> kernel/coinstats",
|
|
"kernel/mempool_persist -> validation -> kernel/mempool_persist",
|
|
|
|
# Temporary, removed in followup https://github.com/bitcoin/bitcoin/pull/24230
|
|
"index/base -> node/context -> net_processing -> index/blockfilterindex -> index/base",
|
|
)
|
|
|
|
CODE_DIR = "src"
|
|
|
|
|
|
def main():
|
|
circular_dependencies = []
|
|
exit_code = 0
|
|
|
|
os.chdir(CODE_DIR)
|
|
files = subprocess.check_output(
|
|
['git', 'ls-files', '--', '*.h', '*.cpp'],
|
|
universal_newlines=True,
|
|
).splitlines()
|
|
|
|
command = [sys.executable, "../contrib/devtools/circular-dependencies.py", *files]
|
|
dependencies_output = subprocess.run(
|
|
command,
|
|
stdout=subprocess.PIPE,
|
|
universal_newlines=True,
|
|
)
|
|
|
|
for dependency_str in dependencies_output.stdout.rstrip().split("\n"):
|
|
circular_dependencies.append(
|
|
re.sub("^Circular dependency: ", "", dependency_str)
|
|
)
|
|
|
|
# Check for an unexpected dependencies
|
|
for dependency in circular_dependencies:
|
|
if dependency not in EXPECTED_CIRCULAR_DEPENDENCIES:
|
|
exit_code = 1
|
|
print(
|
|
f'A new circular dependency in the form of "{dependency}" appears to have been introduced.\n',
|
|
file=sys.stderr,
|
|
)
|
|
|
|
# Check for missing expected dependencies
|
|
for expected_dependency in EXPECTED_CIRCULAR_DEPENDENCIES:
|
|
if expected_dependency not in circular_dependencies:
|
|
exit_code = 1
|
|
print(
|
|
f'Good job! The circular dependency "{expected_dependency}" is no longer present.',
|
|
)
|
|
print(
|
|
f"Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in {__file__}",
|
|
)
|
|
print(
|
|
"to make sure this circular dependency is not accidentally reintroduced.\n",
|
|
)
|
|
|
|
sys.exit(exit_code)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|