chia-blockchain 2.5.0rc1__py3-none-any.whl → 2.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chia/_tests/README.md +1 -1
- chia/_tests/blockchain/blockchain_test_utils.py +24 -26
- chia/_tests/blockchain/test_augmented_chain.py +6 -8
- chia/_tests/blockchain/test_blockchain.py +409 -307
- chia/_tests/blockchain/test_blockchain_transactions.py +56 -75
- chia/_tests/blockchain/test_build_chains.py +11 -13
- chia/_tests/blockchain/test_get_block_generator.py +8 -8
- chia/_tests/blockchain/test_lookup_fork_chain.py +3 -4
- chia/_tests/build-init-files.py +3 -4
- chia/_tests/build-job-matrix.py +9 -9
- chia/_tests/check_sql_statements.py +2 -3
- chia/_tests/clvm/benchmark_costs.py +1 -1
- chia/_tests/clvm/coin_store.py +7 -5
- chia/_tests/clvm/test_chialisp_deserialization.py +8 -8
- chia/_tests/clvm/test_condition_codes.py +2 -2
- chia/_tests/clvm/test_curry_and_treehash.py +2 -4
- chia/_tests/clvm/test_message_conditions.py +184 -0
- chia/_tests/clvm/test_puzzle_compression.py +1 -2
- chia/_tests/clvm/test_puzzle_drivers.py +3 -3
- chia/_tests/clvm/test_puzzles.py +13 -18
- chia/_tests/clvm/test_singletons.py +17 -17
- chia/_tests/clvm/test_spend_sim.py +7 -7
- chia/_tests/cmds/cmd_test_utils.py +42 -45
- chia/_tests/cmds/conftest.py +2 -2
- chia/_tests/cmds/test_click_types.py +21 -16
- chia/_tests/cmds/test_cmd_framework.py +255 -35
- chia/_tests/cmds/test_cmds_util.py +2 -2
- chia/_tests/cmds/test_daemon.py +3 -3
- chia/_tests/cmds/test_dev_gh.py +131 -0
- chia/_tests/cmds/test_farm_cmd.py +1 -2
- chia/_tests/cmds/test_show.py +6 -6
- chia/_tests/cmds/test_tx_config_args.py +2 -1
- chia/_tests/cmds/wallet/test_dao.py +23 -23
- chia/_tests/cmds/wallet/test_did.py +29 -29
- chia/_tests/cmds/wallet/test_nft.py +24 -23
- chia/_tests/cmds/wallet/test_notifications.py +8 -8
- chia/_tests/cmds/wallet/test_tx_decorators.py +3 -3
- chia/_tests/cmds/wallet/test_vcs.py +97 -73
- chia/_tests/cmds/wallet/test_wallet.py +74 -75
- chia/_tests/cmds/wallet/test_wallet_check.py +5 -7
- chia/_tests/conftest.py +153 -38
- chia/_tests/connection_utils.py +7 -6
- chia/_tests/core/cmds/test_beta.py +3 -3
- chia/_tests/core/cmds/test_keys.py +6 -6
- chia/_tests/core/cmds/test_wallet.py +3 -3
- chia/_tests/core/consensus/test_block_creation.py +3 -5
- chia/_tests/core/custom_types/test_coin.py +1 -3
- chia/_tests/core/custom_types/test_spend_bundle.py +3 -4
- chia/_tests/core/daemon/test_daemon.py +58 -58
- chia/_tests/core/daemon/test_keychain_proxy.py +2 -1
- chia/_tests/core/data_layer/conftest.py +4 -3
- chia/_tests/core/data_layer/test_data_cli.py +1 -2
- chia/_tests/core/data_layer/test_data_layer.py +5 -5
- chia/_tests/core/data_layer/test_data_layer_util.py +8 -9
- chia/_tests/core/data_layer/test_data_rpc.py +75 -93
- chia/_tests/core/data_layer/test_data_store.py +38 -37
- chia/_tests/core/data_layer/test_data_store_schema.py +11 -11
- chia/_tests/core/data_layer/util.py +11 -10
- chia/_tests/core/farmer/test_farmer_api.py +6 -4
- chia/_tests/core/full_node/full_sync/test_full_sync.py +5 -10
- chia/_tests/core/full_node/ram_db.py +2 -2
- chia/_tests/core/full_node/stores/test_block_store.py +113 -11
- chia/_tests/core/full_node/stores/test_coin_store.py +37 -28
- chia/_tests/core/full_node/stores/test_full_node_store.py +34 -30
- chia/_tests/core/full_node/stores/test_hint_store.py +3 -4
- chia/_tests/core/full_node/test_address_manager.py +2 -2
- chia/_tests/core/full_node/test_block_height_map.py +1 -1
- chia/_tests/core/full_node/test_conditions.py +10 -12
- chia/_tests/core/full_node/test_full_node.py +2077 -1822
- chia/_tests/core/full_node/test_generator_tools.py +4 -4
- chia/_tests/core/full_node/test_hint_management.py +2 -2
- chia/_tests/core/full_node/test_performance.py +2 -5
- chia/_tests/core/full_node/test_subscriptions.py +4 -4
- chia/_tests/core/full_node/test_tx_processing_queue.py +5 -4
- chia/_tests/core/make_block_generator.py +5 -7
- chia/_tests/core/mempool/test_mempool.py +205 -208
- chia/_tests/core/mempool/test_mempool_fee_protocol.py +5 -5
- chia/_tests/core/mempool/test_mempool_item_queries.py +2 -4
- chia/_tests/core/mempool/test_mempool_manager.py +109 -80
- chia/_tests/core/mempool/test_mempool_performance.py +3 -4
- chia/_tests/core/mempool/test_singleton_fast_forward.py +12 -12
- chia/_tests/core/server/flood.py +6 -4
- chia/_tests/core/server/serve.py +10 -7
- chia/_tests/core/server/test_api_protocol.py +21 -0
- chia/_tests/core/server/test_capabilities.py +3 -5
- chia/_tests/core/server/test_dos.py +15 -16
- chia/_tests/core/server/test_loop.py +14 -10
- chia/_tests/core/server/test_node_discovery.py +1 -2
- chia/_tests/core/server/test_rate_limits.py +156 -44
- chia/_tests/core/server/test_server.py +8 -7
- chia/_tests/core/services/test_services.py +59 -37
- chia/_tests/core/ssl/test_ssl.py +5 -3
- chia/_tests/core/test_cost_calculation.py +5 -6
- chia/_tests/core/test_crawler.py +2 -2
- chia/_tests/core/test_db_conversion.py +5 -4
- chia/_tests/core/test_db_validation.py +6 -5
- chia/_tests/core/test_farmer_harvester_rpc.py +8 -7
- chia/_tests/core/test_filter.py +3 -5
- chia/_tests/core/test_full_node_rpc.py +64 -90
- chia/_tests/core/test_merkle_set.py +10 -10
- chia/_tests/core/test_program.py +2 -4
- chia/_tests/core/test_rpc_util.py +1 -2
- chia/_tests/core/test_seeder.py +124 -12
- chia/_tests/core/util/test_block_cache.py +5 -5
- chia/_tests/core/util/test_cached_bls.py +3 -3
- chia/_tests/core/util/test_config.py +13 -13
- chia/_tests/core/util/test_files.py +2 -2
- chia/_tests/core/util/test_jsonify.py +9 -9
- chia/_tests/core/util/test_keychain.py +13 -5
- chia/_tests/core/util/test_keyring_wrapper.py +6 -5
- chia/_tests/core/util/test_log_exceptions.py +3 -3
- chia/_tests/core/util/test_streamable.py +38 -38
- chia/_tests/db/test_db_wrapper.py +13 -12
- chia/_tests/environments/common.py +2 -2
- chia/_tests/environments/full_node.py +2 -2
- chia/_tests/environments/wallet.py +109 -48
- chia/_tests/farmer_harvester/test_farmer.py +35 -35
- chia/_tests/farmer_harvester/test_farmer_harvester.py +17 -17
- chia/_tests/farmer_harvester/test_filter_prefix_bits.py +6 -5
- chia/_tests/farmer_harvester/test_third_party_harvesters.py +73 -46
- chia/_tests/fee_estimation/test_fee_estimation_integration.py +8 -8
- chia/_tests/fee_estimation/test_fee_estimation_rpc.py +47 -47
- chia/_tests/fee_estimation/test_fee_estimation_unit_tests.py +6 -7
- chia/_tests/fee_estimation/test_mempoolitem_height_added.py +11 -11
- chia/_tests/generator/test_compression.py +13 -30
- chia/_tests/generator/test_generator_types.py +3 -3
- chia/_tests/generator/test_rom.py +7 -9
- chia/_tests/plot_sync/test_delta.py +2 -3
- chia/_tests/plot_sync/test_plot_sync.py +25 -24
- chia/_tests/plot_sync/test_receiver.py +9 -9
- chia/_tests/plot_sync/test_sender.py +1 -1
- chia/_tests/plot_sync/test_sync_simulated.py +27 -26
- chia/_tests/plot_sync/util.py +2 -1
- chia/_tests/plotting/test_plot_manager.py +54 -11
- chia/_tests/plotting/util.py +2 -3
- chia/_tests/pools/test_pool_cli_parsing.py +128 -0
- chia/_tests/pools/test_pool_cmdline.py +993 -15
- chia/_tests/pools/test_pool_config.py +3 -5
- chia/_tests/pools/test_pool_puzzles_lifecycle.py +10 -11
- chia/_tests/pools/test_pool_rpc.py +203 -90
- chia/_tests/pools/test_pool_wallet.py +12 -8
- chia/_tests/pools/test_wallet_pool_store.py +3 -3
- chia/_tests/process_junit.py +16 -17
- chia/_tests/rpc/test_rpc_client.py +59 -2
- chia/_tests/rpc/test_rpc_server.py +183 -0
- chia/_tests/simulation/test_simulation.py +5 -5
- chia/_tests/simulation/test_simulator.py +8 -10
- chia/_tests/simulation/test_start_simulator.py +5 -4
- chia/_tests/timelord/test_new_peak.py +19 -19
- chia/_tests/tools/test_run_block.py +1 -2
- chia/_tests/tools/test_virtual_project.py +591 -0
- chia/_tests/util/benchmark_cost.py +9 -9
- chia/_tests/util/benchmarks.py +1 -2
- chia/_tests/util/blockchain.py +12 -11
- chia/_tests/util/blockchain_mock.py +15 -15
- chia/_tests/util/build_network_protocol_files.py +12 -12
- chia/_tests/util/db_connection.py +3 -2
- chia/_tests/util/full_sync.py +14 -6
- chia/_tests/util/gen_ssl_certs.py +4 -5
- chia/_tests/util/generator_tools_testing.py +5 -7
- chia/_tests/util/get_name_puzzle_conditions.py +52 -0
- chia/_tests/util/key_tool.py +2 -3
- chia/_tests/util/misc.py +59 -106
- chia/_tests/util/network_protocol_data.py +7 -9
- chia/_tests/util/protocol_messages_json.py +112 -111
- chia/_tests/util/rpc.py +3 -0
- chia/_tests/util/run_block.py +16 -16
- chia/_tests/util/setup_nodes.py +25 -23
- chia/{clvm → _tests/util}/spend_sim.py +59 -55
- chia/_tests/util/split_managers.py +12 -9
- chia/_tests/util/temp_file.py +1 -1
- chia/_tests/util/test_action_scope.py +2 -1
- chia/_tests/util/test_async_pool.py +8 -8
- chia/_tests/util/test_build_job_matrix.py +2 -3
- chia/_tests/util/test_condition_tools.py +4 -6
- chia/_tests/util/test_config.py +5 -5
- chia/_tests/util/test_dump_keyring.py +1 -1
- chia/_tests/util/test_full_block_utils.py +19 -11
- chia/_tests/util/test_limited_semaphore.py +4 -3
- chia/_tests/util/test_logging_filter.py +2 -3
- chia/_tests/util/test_misc.py +29 -28
- chia/_tests/util/test_network.py +32 -31
- chia/_tests/util/test_network_protocol_files.py +2 -3
- chia/_tests/util/test_network_protocol_json.py +1 -0
- chia/_tests/util/test_network_protocol_test.py +18 -19
- chia/_tests/util/test_paginator.py +3 -4
- chia/_tests/util/test_pprint.py +1 -1
- chia/_tests/util/test_priority_mutex.py +18 -17
- chia/_tests/util/test_recursive_replace.py +2 -2
- chia/_tests/util/test_testnet_overrides.py +3 -3
- chia/_tests/util/test_timing.py +1 -1
- chia/_tests/util/test_trusted_peer.py +2 -2
- chia/_tests/util/time_out_assert.py +43 -6
- chia/_tests/wallet/cat_wallet/test_cat_lifecycle.py +13 -13
- chia/_tests/wallet/cat_wallet/test_cat_outer_puzzle.py +1 -1
- chia/_tests/wallet/cat_wallet/test_cat_wallet.py +117 -29
- chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py +15 -15
- chia/_tests/wallet/cat_wallet/test_trades.py +50 -28
- chia/_tests/wallet/clawback/test_clawback_decorator.py +3 -5
- chia/_tests/wallet/clawback/test_clawback_lifecycle.py +6 -6
- chia/_tests/wallet/clawback/test_clawback_metadata.py +1 -2
- chia/_tests/wallet/conftest.py +135 -74
- chia/_tests/wallet/dao_wallet/test_dao_clvm.py +25 -17
- chia/_tests/wallet/dao_wallet/test_dao_wallets.py +75 -75
- chia/_tests/wallet/db_wallet/test_db_graftroot.py +10 -12
- chia/_tests/wallet/db_wallet/test_dl_offers.py +6 -6
- chia/_tests/wallet/db_wallet/test_dl_wallet.py +18 -18
- chia/_tests/wallet/did_wallet/test_did.py +1277 -474
- chia/_tests/wallet/nft_wallet/test_nft_1_offers.py +12 -11
- chia/_tests/wallet/nft_wallet/test_nft_bulk_mint.py +115 -105
- chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py +6 -7
- chia/_tests/wallet/nft_wallet/test_nft_offers.py +16 -16
- chia/_tests/wallet/nft_wallet/test_nft_puzzles.py +3 -3
- chia/_tests/wallet/nft_wallet/test_nft_wallet.py +38 -12
- chia/_tests/wallet/nft_wallet/test_ownership_outer_puzzle.py +1 -1
- chia/_tests/wallet/rpc/test_dl_wallet_rpc.py +31 -33
- chia/_tests/wallet/rpc/test_wallet_rpc.py +218 -171
- chia/_tests/wallet/simple_sync/test_simple_sync_protocol.py +36 -37
- chia/_tests/wallet/sync/test_wallet_sync.py +241 -78
- chia/_tests/wallet/test_address_type.py +20 -20
- chia/_tests/wallet/test_clvm_streamable.py +5 -5
- chia/_tests/wallet/test_coin_management.py +354 -0
- chia/_tests/wallet/test_coin_selection.py +34 -35
- chia/_tests/wallet/test_conditions.py +28 -16
- chia/_tests/wallet/test_debug_spend_bundle.py +156 -14
- chia/_tests/wallet/test_new_wallet_protocol.py +29 -31
- chia/_tests/wallet/test_nft_store.py +1 -2
- chia/_tests/wallet/test_notifications.py +2 -2
- chia/_tests/wallet/test_offer_parsing_performance.py +1 -1
- chia/_tests/wallet/test_puzzle_store.py +2 -3
- chia/_tests/wallet/test_sign_coin_spends.py +3 -3
- chia/_tests/wallet/test_signer_protocol.py +33 -34
- chia/_tests/wallet/test_singleton_lifecycle_fast.py +29 -29
- chia/_tests/wallet/test_taproot.py +1 -1
- chia/_tests/wallet/test_transaction_store.py +23 -19
- chia/_tests/wallet/test_util.py +36 -32
- chia/_tests/wallet/test_wallet.py +37 -37
- chia/_tests/wallet/test_wallet_action_scope.py +8 -8
- chia/_tests/wallet/test_wallet_blockchain.py +4 -6
- chia/_tests/wallet/test_wallet_coin_store.py +34 -34
- chia/_tests/wallet/test_wallet_node.py +69 -72
- chia/_tests/wallet/test_wallet_retry.py +3 -3
- chia/_tests/wallet/test_wallet_state_manager.py +12 -5
- chia/_tests/wallet/test_wallet_trade_store.py +2 -2
- chia/_tests/wallet/test_wallet_utils.py +5 -4
- chia/_tests/wallet/vc_wallet/test_cr_outer_puzzle.py +3 -3
- chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py +18 -18
- chia/_tests/wallet/vc_wallet/test_vc_wallet.py +69 -40
- chia/_tests/wallet/wallet_block_tools.py +27 -27
- chia/_tests/weight_proof/test_weight_proof.py +30 -30
- chia/apis.py +19 -0
- chia/cmds/beta.py +8 -7
- chia/cmds/beta_funcs.py +15 -11
- chia/cmds/check_wallet_db.py +29 -27
- chia/cmds/chia.py +17 -9
- chia/cmds/cmd_classes.py +87 -79
- chia/cmds/cmd_helpers.py +242 -0
- chia/cmds/cmds_util.py +56 -66
- chia/cmds/coin_funcs.py +168 -153
- chia/cmds/coins.py +156 -194
- chia/cmds/configure.py +4 -3
- chia/cmds/dao.py +89 -33
- chia/cmds/dao_funcs.py +55 -33
- chia/cmds/data.py +7 -6
- chia/cmds/data_funcs.py +26 -21
- chia/cmds/db.py +4 -3
- chia/cmds/db_backup_func.py +2 -2
- chia/cmds/db_upgrade_func.py +3 -3
- chia/cmds/db_validate_func.py +2 -2
- chia/cmds/dev.py +2 -0
- chia/cmds/farm.py +18 -5
- chia/cmds/farm_funcs.py +17 -24
- chia/cmds/gh.py +275 -0
- chia/cmds/init.py +4 -11
- chia/cmds/init_funcs.py +9 -9
- chia/cmds/installers.py +5 -3
- chia/cmds/keys.py +56 -39
- chia/cmds/keys_funcs.py +30 -31
- chia/cmds/netspace.py +6 -3
- chia/cmds/netspace_funcs.py +3 -2
- chia/cmds/param_types.py +16 -6
- chia/cmds/passphrase.py +8 -7
- chia/cmds/passphrase_funcs.py +7 -61
- chia/cmds/peer.py +2 -1
- chia/cmds/peer_funcs.py +5 -5
- chia/cmds/plotnft.py +207 -153
- chia/cmds/plotnft_funcs.py +205 -174
- chia/cmds/plots.py +14 -6
- chia/cmds/plotters.py +2 -1
- chia/cmds/rpc.py +48 -28
- chia/cmds/show.py +2 -1
- chia/cmds/show_funcs.py +7 -6
- chia/cmds/signer.py +50 -58
- chia/cmds/sim.py +22 -14
- chia/cmds/sim_funcs.py +11 -11
- chia/cmds/start.py +3 -3
- chia/cmds/start_funcs.py +9 -12
- chia/cmds/stop.py +4 -3
- chia/cmds/units.py +1 -3
- chia/cmds/wallet.py +252 -96
- chia/cmds/wallet_funcs.py +217 -143
- chia/consensus/block_body_validation.py +133 -86
- chia/consensus/block_creation.py +42 -21
- chia/consensus/block_header_validation.py +32 -37
- chia/consensus/block_record.py +1 -2
- chia/consensus/blockchain.py +167 -180
- chia/consensus/blockchain_interface.py +10 -10
- chia/consensus/constants.py +2 -2
- chia/consensus/default_constants.py +3 -4
- chia/consensus/difficulty_adjustment.py +5 -5
- chia/consensus/find_fork_point.py +5 -5
- chia/consensus/full_block_to_block_record.py +4 -4
- chia/consensus/get_block_challenge.py +2 -2
- chia/consensus/get_block_generator.py +4 -3
- chia/consensus/multiprocess_validation.py +207 -304
- chia/consensus/vdf_info_computation.py +3 -3
- chia/daemon/client.py +46 -27
- chia/daemon/keychain_proxy.py +10 -9
- chia/daemon/keychain_server.py +18 -18
- chia/daemon/server.py +103 -113
- chia/daemon/windows_signal.py +2 -2
- chia/data_layer/data_layer.py +64 -76
- chia/data_layer/data_layer_api.py +8 -0
- chia/data_layer/data_layer_errors.py +3 -3
- chia/data_layer/data_layer_server.py +2 -2
- chia/data_layer/data_layer_util.py +71 -71
- chia/data_layer/data_layer_wallet.py +63 -67
- chia/data_layer/data_store.py +72 -72
- chia/data_layer/dl_wallet_store.py +10 -10
- chia/data_layer/download_data.py +5 -5
- chia/data_layer/s3_plugin_service.py +9 -9
- chia/data_layer/util/benchmark.py +0 -1
- chia/data_layer/util/plugin.py +2 -3
- chia/farmer/farmer.py +46 -43
- chia/farmer/farmer_api.py +27 -21
- chia/full_node/block_height_map.py +6 -6
- chia/full_node/block_store.py +41 -35
- chia/full_node/coin_store.py +42 -41
- chia/full_node/fee_estimate.py +2 -2
- chia/full_node/fee_estimation.py +1 -2
- chia/full_node/fee_history.py +5 -6
- chia/full_node/fee_tracker.py +24 -24
- chia/full_node/full_node.py +574 -300
- chia/full_node/full_node_api.py +181 -130
- chia/full_node/full_node_store.py +43 -43
- chia/full_node/hint_management.py +4 -4
- chia/full_node/hint_store.py +9 -10
- chia/full_node/mempool.py +25 -19
- chia/full_node/mempool_check_conditions.py +11 -42
- chia/full_node/mempool_manager.py +48 -53
- chia/full_node/pending_tx_cache.py +9 -9
- chia/full_node/subscriptions.py +23 -24
- chia/full_node/sync_store.py +8 -7
- chia/full_node/tx_processing_queue.py +3 -3
- chia/full_node/util/__init__.py +0 -0
- chia/full_node/weight_proof.py +79 -78
- chia/harvester/harvester.py +9 -8
- chia/harvester/harvester_api.py +19 -13
- chia/introducer/introducer.py +7 -5
- chia/introducer/introducer_api.py +9 -3
- chia/legacy/keyring.py +6 -5
- chia/plot_sync/delta.py +8 -8
- chia/plot_sync/receiver.py +12 -11
- chia/plot_sync/sender.py +15 -12
- chia/plotters/bladebit.py +12 -12
- chia/plotters/chiapos.py +2 -2
- chia/plotters/madmax.py +8 -8
- chia/plotters/plotters.py +6 -6
- chia/plotters/plotters_util.py +6 -4
- chia/plotting/cache.py +8 -7
- chia/plotting/check_plots.py +8 -8
- chia/plotting/create_plots.py +6 -6
- chia/plotting/manager.py +22 -22
- chia/plotting/util.py +31 -19
- chia/pools/pool_config.py +7 -7
- chia/pools/pool_puzzles.py +16 -16
- chia/pools/pool_wallet.py +64 -57
- chia/pools/pool_wallet_info.py +3 -3
- chia/protocols/full_node_protocol.py +3 -3
- chia/protocols/harvester_protocol.py +12 -12
- chia/protocols/introducer_protocol.py +1 -2
- chia/protocols/protocol_message_types.py +4 -4
- chia/protocols/protocol_state_machine.py +2 -2
- chia/protocols/protocol_timing.py +1 -0
- chia/protocols/shared_protocol.py +3 -3
- chia/protocols/timelord_protocol.py +2 -2
- chia/protocols/wallet_protocol.py +33 -33
- chia/rpc/crawler_rpc_api.py +12 -7
- chia/rpc/data_layer_rpc_api.py +49 -44
- chia/rpc/data_layer_rpc_client.py +41 -41
- chia/rpc/data_layer_rpc_util.py +7 -11
- chia/rpc/farmer_rpc_api.py +32 -27
- chia/rpc/farmer_rpc_client.py +14 -14
- chia/rpc/full_node_rpc_api.py +53 -48
- chia/rpc/full_node_rpc_client.py +30 -30
- chia/rpc/harvester_rpc_api.py +16 -11
- chia/rpc/harvester_rpc_client.py +6 -6
- chia/rpc/rpc_client.py +34 -14
- chia/rpc/rpc_server.py +117 -43
- chia/rpc/timelord_rpc_api.py +9 -4
- chia/rpc/util.py +11 -211
- chia/rpc/wallet_request_types.py +276 -60
- chia/rpc/wallet_rpc_api.py +563 -399
- chia/rpc/wallet_rpc_client.py +220 -250
- chia/seeder/crawl_store.py +6 -8
- chia/seeder/crawler.py +23 -36
- chia/seeder/crawler_api.py +28 -22
- chia/seeder/dns_server.py +99 -50
- chia/seeder/start_crawler.py +13 -9
- chia/server/address_manager.py +19 -19
- chia/server/address_manager_store.py +17 -17
- chia/server/api_protocol.py +106 -1
- chia/server/capabilities.py +3 -3
- chia/server/chia_policy.py +17 -16
- chia/server/introducer_peers.py +3 -3
- chia/server/node_discovery.py +34 -38
- chia/server/rate_limit_numbers.py +26 -16
- chia/server/rate_limits.py +67 -27
- chia/server/server.py +52 -31
- chia/server/signal_handlers.py +6 -3
- chia/server/ssl_context.py +5 -5
- chia/server/start_data_layer.py +37 -23
- chia/server/start_farmer.py +28 -16
- chia/server/start_full_node.py +29 -23
- chia/server/start_harvester.py +28 -15
- chia/server/start_introducer.py +27 -15
- chia/server/start_service.py +17 -29
- chia/server/start_timelord.py +25 -18
- chia/server/start_wallet.py +22 -18
- chia/server/upnp.py +4 -3
- chia/server/ws_connection.py +68 -54
- chia/simulator/add_blocks_in_batches.py +54 -0
- chia/simulator/block_tools.py +65 -64
- chia/simulator/full_node_simulator.py +66 -74
- chia/simulator/setup_services.py +10 -9
- chia/simulator/simulator_full_node_rpc_api.py +12 -14
- chia/simulator/simulator_full_node_rpc_client.py +3 -5
- chia/simulator/simulator_test_tools.py +8 -7
- chia/simulator/socket.py +1 -4
- chia/simulator/ssl_certs.py +5 -5
- chia/simulator/ssl_certs_1.py +2 -4
- chia/simulator/ssl_certs_10.py +2 -4
- chia/simulator/ssl_certs_2.py +2 -4
- chia/simulator/ssl_certs_3.py +2 -4
- chia/simulator/ssl_certs_4.py +2 -4
- chia/simulator/ssl_certs_5.py +2 -4
- chia/simulator/ssl_certs_6.py +2 -4
- chia/simulator/ssl_certs_7.py +2 -4
- chia/simulator/ssl_certs_8.py +2 -4
- chia/simulator/ssl_certs_9.py +2 -4
- chia/simulator/start_simulator.py +14 -6
- chia/simulator/wallet_tools.py +21 -20
- chia/ssl/create_ssl.py +11 -11
- chia/timelord/iters_from_block.py +2 -2
- chia/timelord/timelord.py +57 -33
- chia/timelord/timelord_api.py +12 -6
- chia/timelord/timelord_launcher.py +10 -8
- chia/timelord/timelord_state.py +5 -5
- chia/types/block_protocol.py +2 -2
- chia/types/blockchain_format/coin.py +3 -3
- chia/types/blockchain_format/program.py +17 -18
- chia/types/blockchain_format/tree_hash.py +9 -9
- chia/types/coin_spend.py +8 -8
- chia/types/condition_with_args.py +1 -2
- chia/types/eligible_coin_spends.py +16 -15
- chia/types/generator_types.py +1 -2
- chia/types/internal_mempool_item.py +1 -2
- chia/types/mempool_item.py +7 -7
- chia/types/mempool_submission_status.py +2 -2
- chia/types/peer_info.py +1 -1
- chia/types/spend_bundle.py +1 -2
- chia/types/transaction_queue_entry.py +2 -2
- chia/types/unfinished_header_block.py +2 -2
- chia/types/validation_state.py +14 -0
- chia/types/weight_proof.py +5 -6
- chia/util/action_scope.py +8 -8
- chia/util/async_pool.py +6 -4
- chia/util/augmented_chain.py +13 -9
- chia/util/batches.py +5 -2
- chia/util/bech32m.py +14 -11
- chia/util/beta_metrics.py +5 -4
- chia/util/block_cache.py +5 -5
- chia/util/byte_types.py +2 -0
- chia/util/check_fork_next_block.py +3 -2
- chia/util/chia_logging.py +41 -21
- chia/util/collection.py +3 -3
- chia/util/condition_tools.py +18 -18
- chia/util/config.py +26 -25
- chia/util/cpu.py +2 -0
- chia/util/db_synchronous.py +2 -0
- chia/util/db_version.py +2 -0
- chia/util/db_wrapper.py +13 -10
- chia/util/default_root.py +17 -0
- chia/util/dump_keyring.py +6 -6
- chia/util/errors.py +5 -3
- chia/util/file_keyring.py +22 -33
- chia/util/files.py +2 -0
- chia/util/full_block_utils.py +31 -7
- chia/util/generator_tools.py +18 -8
- chia/util/hash.py +3 -1
- chia/util/initial-config.yaml +19 -0
- chia/util/inline_executor.py +2 -0
- chia/util/ip_address.py +39 -0
- chia/util/json_util.py +0 -4
- chia/util/keychain.py +27 -24
- chia/util/keyring_wrapper.py +65 -4
- chia/util/limited_semaphore.py +3 -1
- chia/util/lock.py +4 -2
- chia/util/log_exceptions.py +5 -2
- chia/util/logging.py +3 -1
- chia/util/lru_cache.py +2 -0
- chia/util/math.py +4 -4
- chia/util/network.py +15 -73
- chia/util/paginator.py +3 -1
- chia/util/path.py +2 -0
- chia/util/permissions.py +3 -2
- chia/util/prev_transaction_block.py +1 -3
- chia/util/priority_mutex.py +6 -3
- chia/util/profiler.py +7 -4
- chia/util/recursive_replace.py +2 -0
- chia/util/safe_cancel_task.py +2 -0
- chia/util/service_groups.py +2 -2
- chia/util/setproctitle.py +2 -0
- chia/util/significant_bits.py +2 -0
- chia/util/ssl_check.py +11 -11
- chia/util/streamable.py +44 -56
- chia/util/task_referencer.py +59 -0
- chia/util/task_timing.py +22 -18
- chia/util/timing.py +4 -1
- chia/util/vdf_prover.py +2 -3
- chia/util/virtual_project_analysis.py +540 -0
- chia/util/ws_message.py +6 -6
- chia/wallet/cat_wallet/cat_info.py +3 -3
- chia/wallet/cat_wallet/cat_outer_puzzle.py +3 -3
- chia/wallet/cat_wallet/cat_utils.py +5 -4
- chia/wallet/cat_wallet/cat_wallet.py +56 -70
- chia/wallet/cat_wallet/dao_cat_info.py +3 -3
- chia/wallet/cat_wallet/dao_cat_wallet.py +18 -18
- chia/wallet/cat_wallet/lineage_store.py +2 -2
- chia/wallet/coin_selection.py +15 -15
- chia/wallet/conditions.py +257 -71
- chia/wallet/dao_wallet/dao_info.py +4 -4
- chia/wallet/dao_wallet/dao_utils.py +43 -42
- chia/wallet/dao_wallet/dao_wallet.py +66 -68
- chia/wallet/db_wallet/db_wallet_puzzles.py +12 -8
- chia/wallet/derive_keys.py +11 -11
- chia/wallet/did_wallet/did_info.py +3 -3
- chia/wallet/did_wallet/did_wallet.py +56 -47
- chia/wallet/did_wallet/did_wallet_puzzles.py +7 -6
- chia/wallet/lineage_proof.py +4 -4
- chia/wallet/nft_wallet/metadata_outer_puzzle.py +2 -2
- chia/wallet/nft_wallet/nft_info.py +4 -4
- chia/wallet/nft_wallet/nft_puzzles.py +16 -16
- chia/wallet/nft_wallet/nft_wallet.py +90 -89
- chia/wallet/nft_wallet/ownership_outer_puzzle.py +2 -2
- chia/wallet/nft_wallet/singleton_outer_puzzle.py +2 -2
- chia/wallet/nft_wallet/transfer_program_puzzle.py +2 -2
- chia/wallet/nft_wallet/uncurry_nft.py +2 -2
- chia/wallet/notification_manager.py +5 -5
- chia/wallet/notification_store.py +6 -6
- chia/wallet/outer_puzzles.py +2 -2
- chia/wallet/payment.py +4 -5
- chia/wallet/puzzle_drivers.py +4 -4
- chia/wallet/puzzles/clawback/drivers.py +5 -5
- chia/wallet/puzzles/clawback/puzzle_decorator.py +7 -7
- chia/wallet/puzzles/load_clvm.py +2 -3
- chia/wallet/puzzles/p2_conditions.py +1 -2
- chia/wallet/puzzles/p2_delegated_conditions.py +1 -2
- chia/wallet/puzzles/p2_delegated_puzzle.py +2 -3
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +3 -4
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.py +1 -2
- chia/wallet/puzzles/p2_puzzle_hash.py +1 -2
- chia/wallet/puzzles/puzzle_utils.py +7 -7
- chia/wallet/puzzles/singleton_top_layer.py +6 -5
- chia/wallet/puzzles/singleton_top_layer_v1_1.py +6 -5
- chia/wallet/puzzles/tails.py +34 -30
- chia/wallet/signer_protocol.py +7 -8
- chia/wallet/singleton.py +4 -4
- chia/wallet/trade_manager.py +155 -141
- chia/wallet/trade_record.py +5 -5
- chia/wallet/trading/offer.py +100 -101
- chia/wallet/trading/trade_store.py +14 -14
- chia/wallet/transaction_record.py +31 -16
- chia/wallet/util/address_type.py +4 -4
- chia/wallet/util/blind_signer_tl.py +8 -12
- chia/wallet/util/clvm_streamable.py +15 -15
- chia/wallet/util/compute_hints.py +5 -5
- chia/wallet/util/compute_memos.py +4 -6
- chia/wallet/util/curry_and_treehash.py +3 -2
- chia/wallet/util/debug_spend_bundle.py +6 -8
- chia/wallet/util/merkle_tree.py +10 -10
- chia/wallet/util/merkle_utils.py +10 -10
- chia/wallet/util/new_peak_queue.py +3 -3
- chia/wallet/util/peer_request_cache.py +8 -8
- chia/{util → wallet/util}/pprint.py +2 -3
- chia/wallet/util/puzzle_compression.py +3 -4
- chia/wallet/util/puzzle_decorator.py +10 -10
- chia/wallet/util/query_filter.py +9 -10
- chia/wallet/util/tx_config.py +12 -12
- chia/wallet/util/wallet_sync_utils.py +24 -21
- chia/wallet/util/wallet_types.py +9 -2
- chia/wallet/vc_wallet/cr_cat_drivers.py +28 -27
- chia/wallet/vc_wallet/cr_cat_wallet.py +42 -40
- chia/wallet/vc_wallet/cr_outer_puzzle.py +4 -4
- chia/wallet/vc_wallet/vc_drivers.py +16 -16
- chia/wallet/vc_wallet/vc_store.py +9 -9
- chia/wallet/vc_wallet/vc_wallet.py +35 -35
- chia/wallet/wallet.py +54 -54
- chia/wallet/wallet_action_scope.py +14 -13
- chia/wallet/wallet_blockchain.py +10 -10
- chia/wallet/wallet_coin_record.py +2 -2
- chia/wallet/wallet_coin_store.py +10 -10
- chia/wallet/wallet_info.py +1 -2
- chia/wallet/wallet_interested_store.py +5 -5
- chia/wallet/wallet_nft_store.py +6 -6
- chia/wallet/wallet_node.py +72 -76
- chia/wallet/wallet_node_api.py +33 -27
- chia/wallet/wallet_pool_store.py +1 -2
- chia/wallet/wallet_protocol.py +15 -15
- chia/wallet/wallet_puzzle_store.py +35 -4
- chia/wallet/wallet_retry_store.py +2 -2
- chia/wallet/wallet_singleton_store.py +10 -9
- chia/wallet/wallet_spend_bundle.py +4 -20
- chia/wallet/wallet_state_manager.py +223 -224
- chia/wallet/wallet_transaction_store.py +44 -18
- chia/wallet/wallet_user_store.py +2 -2
- chia/wallet/wallet_weight_proof_handler.py +2 -2
- {chia_blockchain-2.5.0rc1.dist-info → chia_blockchain-2.5.1.dist-info}/LICENSE +1 -1
- {chia_blockchain-2.5.0rc1.dist-info → chia_blockchain-2.5.1.dist-info}/METADATA +67 -72
- chia_blockchain-2.5.1.dist-info/RECORD +1042 -0
- {chia_blockchain-2.5.0rc1.dist-info → chia_blockchain-2.5.1.dist-info}/WHEEL +1 -1
- mozilla-ca/cacert.pem +32 -87
- chia/_tests/cmds/wallet/test_coins.py +0 -195
- chia/consensus/block_root_validation.py +0 -46
- chia/util/api_decorators.py +0 -89
- chia_blockchain-2.5.0rc1.dist-info/RECORD +0 -1028
- {chia_blockchain-2.5.0rc1.dist-info → chia_blockchain-2.5.1.dist-info}/entry_points.txt +0 -0
chia/util/beta_metrics.py
CHANGED
|
@@ -6,12 +6,13 @@ import platform
|
|
|
6
6
|
import socket
|
|
7
7
|
from dataclasses import dataclass
|
|
8
8
|
from pathlib import Path
|
|
9
|
-
from typing import Any,
|
|
9
|
+
from typing import Any, Optional
|
|
10
10
|
|
|
11
11
|
import psutil
|
|
12
12
|
|
|
13
13
|
from chia.util.config import load_config
|
|
14
14
|
from chia.util.cpu import available_logical_cores
|
|
15
|
+
from chia.util.task_referencer import create_referenced_task
|
|
15
16
|
|
|
16
17
|
log = logging.getLogger("beta")
|
|
17
18
|
|
|
@@ -43,7 +44,7 @@ def log_memory_metrics() -> None:
|
|
|
43
44
|
log.debug(f"MEMORY - virtual memory: {psutil.virtual_memory()}, swap: {psutil.swap_memory()}")
|
|
44
45
|
|
|
45
46
|
|
|
46
|
-
def log_disk_metrics(root_path: Path, plot_dirs:
|
|
47
|
+
def log_disk_metrics(root_path: Path, plot_dirs: list[str]) -> None:
|
|
47
48
|
# TODO, Could this spam the logs too much for large farms? Maybe don't log usage of plot dirs and
|
|
48
49
|
# set perdisk=False rather for psutil.disk_io_counters? Lets try it with the default interval of 15s for now.
|
|
49
50
|
log.debug(f"DISK partitions: {psutil.disk_partitions()}")
|
|
@@ -57,7 +58,7 @@ def log_disk_metrics(root_path: Path, plot_dirs: List[str]) -> None:
|
|
|
57
58
|
log.debug(f"DISK - io counters: {psutil.disk_io_counters(perdisk=True)}")
|
|
58
59
|
|
|
59
60
|
|
|
60
|
-
def log_port_states(config:
|
|
61
|
+
def log_port_states(config: dict[str, Any]) -> None:
|
|
61
62
|
selected_network = config["selected_network"]
|
|
62
63
|
full_node_port = config["network_overrides"]["config"][selected_network]["default_full_node_port"]
|
|
63
64
|
test_socket_ipv4 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
@@ -84,7 +85,7 @@ class BetaMetricsLogger:
|
|
|
84
85
|
if self.task is not None:
|
|
85
86
|
raise RuntimeError("Already started")
|
|
86
87
|
self.stop_task = False
|
|
87
|
-
self.task =
|
|
88
|
+
self.task = create_referenced_task(self.run())
|
|
88
89
|
|
|
89
90
|
async def stop_logging(self) -> None:
|
|
90
91
|
log.debug("stop_logging")
|
chia/util/block_cache.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING, ClassVar,
|
|
3
|
+
from typing import TYPE_CHECKING, ClassVar, Optional, cast
|
|
4
4
|
|
|
5
5
|
from chia.consensus.block_record import BlockRecord
|
|
6
6
|
from chia.types.blockchain_format.sized_bytes import bytes32
|
|
@@ -14,12 +14,12 @@ class BlockCache:
|
|
|
14
14
|
|
|
15
15
|
_protocol_check: ClassVar[BlockRecordsProtocol] = cast("BlockCache", None)
|
|
16
16
|
|
|
17
|
-
_block_records:
|
|
18
|
-
_height_to_hash:
|
|
17
|
+
_block_records: dict[bytes32, BlockRecord]
|
|
18
|
+
_height_to_hash: dict[uint32, bytes32]
|
|
19
19
|
|
|
20
20
|
def __init__(
|
|
21
21
|
self,
|
|
22
|
-
blocks:
|
|
22
|
+
blocks: dict[bytes32, BlockRecord],
|
|
23
23
|
):
|
|
24
24
|
self._block_records = blocks
|
|
25
25
|
self._height_to_hash = {block.height: hh for hh, block in blocks.items()}
|
|
@@ -52,5 +52,5 @@ class BlockCache:
|
|
|
52
52
|
def try_block_record(self, header_hash: bytes32) -> Optional[BlockRecord]:
|
|
53
53
|
return self._block_records.get(header_hash)
|
|
54
54
|
|
|
55
|
-
async def prev_block_hash(self, header_hashes:
|
|
55
|
+
async def prev_block_hash(self, header_hashes: list[bytes32]) -> list[bytes32]:
|
|
56
56
|
return [self._block_records[h].prev_hash for h in header_hashes]
|
chia/util/byte_types.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from collections.abc import Awaitable
|
|
4
|
+
from typing import Callable
|
|
4
5
|
|
|
5
6
|
from chia.consensus.blockchain_interface import BlockchainInterface
|
|
6
7
|
from chia.server.ws_connection import WSChiaConnection
|
|
@@ -10,7 +11,7 @@ from chia.util.ints import uint32
|
|
|
10
11
|
async def check_fork_next_block(
|
|
11
12
|
blockchain: BlockchainInterface,
|
|
12
13
|
fork_point_height: uint32,
|
|
13
|
-
peers_with_peak:
|
|
14
|
+
peers_with_peak: list[WSChiaConnection],
|
|
14
15
|
check_block_future: Callable[[WSChiaConnection, uint32, BlockchainInterface], Awaitable[bool]],
|
|
15
16
|
) -> uint32:
|
|
16
17
|
our_peak_height = blockchain.get_peak_height()
|
chia/util/chia_logging.py
CHANGED
|
@@ -4,20 +4,19 @@ import logging
|
|
|
4
4
|
import os
|
|
5
5
|
from logging.handlers import SysLogHandler
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from typing import Any,
|
|
7
|
+
from typing import Any, Optional, cast
|
|
8
8
|
|
|
9
9
|
import colorlog
|
|
10
10
|
from concurrent_log_handler import ConcurrentRotatingFileHandler
|
|
11
11
|
|
|
12
12
|
from chia import __version__
|
|
13
13
|
from chia.util.chia_version import chia_short_version
|
|
14
|
-
from chia.util.default_root import DEFAULT_ROOT_PATH
|
|
15
14
|
from chia.util.path import path_from_root
|
|
16
15
|
|
|
17
16
|
default_log_level = "WARNING"
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
def get_beta_logging_config() ->
|
|
19
|
+
def get_beta_logging_config() -> dict[str, Any]:
|
|
21
20
|
return {
|
|
22
21
|
"log_filename": f"{chia_short_version()}/chia-blockchain/beta.log",
|
|
23
22
|
"log_level": "DEBUG",
|
|
@@ -29,7 +28,7 @@ def get_beta_logging_config() -> Dict[str, Any]:
|
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
def get_file_log_handler(
|
|
32
|
-
formatter: logging.Formatter, root_path: Path, logging_config:
|
|
31
|
+
formatter: logging.Formatter, root_path: Path, logging_config: dict[str, object]
|
|
33
32
|
) -> ConcurrentRotatingFileHandler:
|
|
34
33
|
log_path = path_from_root(root_path, str(logging_config.get("log_filename", "log/debug.log")))
|
|
35
34
|
log_path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -45,25 +44,35 @@ def get_file_log_handler(
|
|
|
45
44
|
|
|
46
45
|
def initialize_logging(
|
|
47
46
|
service_name: str,
|
|
48
|
-
logging_config:
|
|
47
|
+
logging_config: dict[str, Any],
|
|
49
48
|
root_path: Path,
|
|
50
49
|
beta_root_path: Optional[Path] = None,
|
|
51
50
|
) -> None:
|
|
51
|
+
log_backcompat = logging_config.get("log_backcompat", False)
|
|
52
52
|
log_level = logging_config.get("log_level", default_log_level)
|
|
53
53
|
file_name_length = 33 - len(service_name)
|
|
54
54
|
log_date_format = "%Y-%m-%dT%H:%M:%S"
|
|
55
55
|
file_log_formatter = logging.Formatter(
|
|
56
|
-
fmt=
|
|
57
|
-
|
|
56
|
+
fmt=(
|
|
57
|
+
f"%(asctime)s.%(msecs)03d {service_name} %(name)-{file_name_length}s: %(levelname)-8s %(message)s"
|
|
58
|
+
if log_backcompat
|
|
59
|
+
else f"%(asctime)s.%(msecs)03d {__version__} {service_name} %(name)-{file_name_length}s: "
|
|
60
|
+
f"%(levelname)-8s %(message)s"
|
|
61
|
+
),
|
|
58
62
|
datefmt=log_date_format,
|
|
59
63
|
)
|
|
60
|
-
handlers:
|
|
64
|
+
handlers: list[logging.Handler] = []
|
|
61
65
|
if logging_config["log_stdout"]:
|
|
62
66
|
stdout_handler = colorlog.StreamHandler()
|
|
63
67
|
stdout_handler.setFormatter(
|
|
64
68
|
colorlog.ColoredFormatter(
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
(
|
|
70
|
+
f"%(asctime)s.%(msecs)03d {service_name} %(name)-{file_name_length}s: "
|
|
71
|
+
f"%(log_color)s%(levelname)-8s%(reset)s %(message)s"
|
|
72
|
+
if log_backcompat
|
|
73
|
+
else f"%(asctime)s.%(msecs)03d {__version__} {service_name} %(name)-{file_name_length}s: "
|
|
74
|
+
f"%(log_color)s%(levelname)-8s%(reset)s %(message)s"
|
|
75
|
+
),
|
|
67
76
|
datefmt=log_date_format,
|
|
68
77
|
reset=True,
|
|
69
78
|
)
|
|
@@ -83,31 +92,42 @@ def initialize_logging(
|
|
|
83
92
|
handlers.append(get_file_log_handler(file_log_formatter, beta_root_path, get_beta_logging_config()))
|
|
84
93
|
|
|
85
94
|
root_logger = logging.getLogger()
|
|
86
|
-
log_level_exceptions = {}
|
|
87
95
|
for handler in handlers:
|
|
96
|
+
root_logger.addHandler(handler)
|
|
97
|
+
|
|
98
|
+
set_log_level(log_level=log_level, service_name=service_name)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def set_log_level(log_level: str, service_name: str) -> list[str]:
|
|
102
|
+
root_logger = logging.getLogger()
|
|
103
|
+
log_level_exceptions = {}
|
|
104
|
+
|
|
105
|
+
for handler in root_logger.handlers:
|
|
88
106
|
try:
|
|
89
107
|
handler.setLevel(log_level)
|
|
90
108
|
except Exception as e:
|
|
91
109
|
handler.setLevel(default_log_level)
|
|
92
110
|
log_level_exceptions[handler] = e
|
|
93
|
-
root_logger.addHandler(handler)
|
|
94
111
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
112
|
+
error_strings = [
|
|
113
|
+
f"Handler {handler}: Invalid log level '{log_level}' for {service_name}. "
|
|
114
|
+
f"Defaulting to: {default_log_level}. Error: {exception}"
|
|
115
|
+
for handler, exception in log_level_exceptions.items()
|
|
116
|
+
]
|
|
117
|
+
for error_string in error_strings:
|
|
118
|
+
root_logger.error(error_string)
|
|
100
119
|
|
|
101
120
|
# Adjust the root logger to the smallest used log level since its default level is WARNING which would overwrite
|
|
102
121
|
# the potentially smaller log levels of specific handlers.
|
|
103
|
-
root_logger.setLevel(min(handler.level for handler in handlers))
|
|
122
|
+
root_logger.setLevel(min(handler.level for handler in root_logger.handlers))
|
|
104
123
|
|
|
105
124
|
if root_logger.level <= logging.DEBUG:
|
|
106
125
|
logging.getLogger("aiosqlite").setLevel(logging.INFO) # Too much logging on debug level
|
|
107
126
|
|
|
127
|
+
return error_strings
|
|
128
|
+
|
|
108
129
|
|
|
109
|
-
def initialize_service_logging(service_name: str, config:
|
|
110
|
-
logging_root_path = DEFAULT_ROOT_PATH
|
|
130
|
+
def initialize_service_logging(service_name: str, config: dict[str, Any], root_path: Path) -> None:
|
|
111
131
|
if service_name == "daemon":
|
|
112
132
|
# TODO: Maybe introduce a separate `daemon` section in the config instead of having `daemon_port`, `logging`
|
|
113
133
|
# and the daemon related stuff as top level entries.
|
|
@@ -119,6 +139,6 @@ def initialize_service_logging(service_name: str, config: Dict[str, Any]) -> Non
|
|
|
119
139
|
initialize_logging(
|
|
120
140
|
service_name=service_name,
|
|
121
141
|
logging_config=logging_config,
|
|
122
|
-
root_path=
|
|
142
|
+
root_path=root_path,
|
|
123
143
|
beta_root_path=beta_config_path,
|
|
124
144
|
)
|
chia/util/collection.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
# Package: utils
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
# Utility Functions for Collections & Sequences
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def find_duplicates(array:
|
|
8
|
+
def find_duplicates(array: list[int]) -> set[int]:
|
|
9
9
|
seen = set()
|
|
10
10
|
duplicates = set()
|
|
11
11
|
|
chia/util/condition_tools.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import lru_cache
|
|
4
|
-
from typing import Callable,
|
|
4
|
+
from typing import Callable, Union
|
|
5
5
|
|
|
6
6
|
from chia_rs import G1Element
|
|
7
7
|
from clvm.casts import int_from_bytes, int_to_bytes
|
|
@@ -33,7 +33,7 @@ def parse_sexp_to_condition(sexp: Program) -> ConditionWithArgs:
|
|
|
33
33
|
# since the ConditionWithArgs only has atoms as the args, we can't parse
|
|
34
34
|
# hints and memos with this function. We just exit the loop if we encounter
|
|
35
35
|
# a pair instead of an atom
|
|
36
|
-
vars:
|
|
36
|
+
vars: list[bytes] = []
|
|
37
37
|
for arg in Program(first[1]).as_iter():
|
|
38
38
|
a = arg.atom
|
|
39
39
|
if a is None:
|
|
@@ -47,7 +47,7 @@ def parse_sexp_to_condition(sexp: Program) -> ConditionWithArgs:
|
|
|
47
47
|
return ConditionWithArgs(ConditionOpcode(op), vars)
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def parse_sexp_to_conditions(sexp: Program) ->
|
|
50
|
+
def parse_sexp_to_conditions(sexp: Program) -> list[ConditionWithArgs]:
|
|
51
51
|
"""
|
|
52
52
|
Takes a ChiaLisp sexp (list) and returns the list of ConditionWithArgss
|
|
53
53
|
Raises an ConsensusError if it fails.
|
|
@@ -56,8 +56,8 @@ def parse_sexp_to_conditions(sexp: Program) -> List[ConditionWithArgs]:
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
@lru_cache
|
|
59
|
-
def agg_sig_additional_data(agg_sig_data: bytes) ->
|
|
60
|
-
ret:
|
|
59
|
+
def agg_sig_additional_data(agg_sig_data: bytes) -> dict[ConditionOpcode, bytes]:
|
|
60
|
+
ret: dict[ConditionOpcode, bytes] = {}
|
|
61
61
|
for code in [
|
|
62
62
|
ConditionOpcode.AGG_SIG_PARENT,
|
|
63
63
|
ConditionOpcode.AGG_SIG_PUZZLE,
|
|
@@ -76,7 +76,7 @@ def make_aggsig_final_message(
|
|
|
76
76
|
opcode: ConditionOpcode,
|
|
77
77
|
msg: bytes,
|
|
78
78
|
spend_conditions: Union[Coin, SpendConditions],
|
|
79
|
-
agg_sig_additional_data:
|
|
79
|
+
agg_sig_additional_data: dict[ConditionOpcode, bytes],
|
|
80
80
|
) -> bytes:
|
|
81
81
|
if isinstance(spend_conditions, Coin):
|
|
82
82
|
coin = spend_conditions
|
|
@@ -85,7 +85,7 @@ def make_aggsig_final_message(
|
|
|
85
85
|
else:
|
|
86
86
|
raise ValueError(f"Expected Coin or Spend, got {type(spend_conditions)}") # pragma: no cover
|
|
87
87
|
|
|
88
|
-
COIN_TO_ADDENDUM_F_LOOKUP:
|
|
88
|
+
COIN_TO_ADDENDUM_F_LOOKUP: dict[ConditionOpcode, Callable[[Coin], bytes]] = {
|
|
89
89
|
ConditionOpcode.AGG_SIG_PARENT: lambda coin: coin.parent_coin_info,
|
|
90
90
|
ConditionOpcode.AGG_SIG_PUZZLE: lambda coin: coin.puzzle_hash,
|
|
91
91
|
ConditionOpcode.AGG_SIG_AMOUNT: lambda coin: int_to_bytes(coin.amount),
|
|
@@ -98,8 +98,8 @@ def make_aggsig_final_message(
|
|
|
98
98
|
return msg + addendum + agg_sig_additional_data[opcode]
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
def pkm_pairs(conditions: SpendBundleConditions, additional_data: bytes) ->
|
|
102
|
-
ret:
|
|
101
|
+
def pkm_pairs(conditions: SpendBundleConditions, additional_data: bytes) -> tuple[list[G1Element], list[bytes]]:
|
|
102
|
+
ret: tuple[list[G1Element], list[bytes]] = ([], [])
|
|
103
103
|
|
|
104
104
|
data = agg_sig_additional_data(additional_data)
|
|
105
105
|
|
|
@@ -137,11 +137,11 @@ def validate_cwa(cwa: ConditionWithArgs) -> None:
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
def pkm_pairs_for_conditions_dict(
|
|
140
|
-
conditions_dict:
|
|
140
|
+
conditions_dict: dict[ConditionOpcode, list[ConditionWithArgs]],
|
|
141
141
|
coin: Coin,
|
|
142
142
|
additional_data: bytes,
|
|
143
|
-
) ->
|
|
144
|
-
ret:
|
|
143
|
+
) -> list[tuple[G1Element, bytes]]:
|
|
144
|
+
ret: list[tuple[G1Element, bytes]] = []
|
|
145
145
|
|
|
146
146
|
data = agg_sig_additional_data(additional_data)
|
|
147
147
|
|
|
@@ -169,9 +169,9 @@ def pkm_pairs_for_conditions_dict(
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
def created_outputs_for_conditions_dict(
|
|
172
|
-
conditions_dict:
|
|
172
|
+
conditions_dict: dict[ConditionOpcode, list[ConditionWithArgs]],
|
|
173
173
|
input_coin_name: bytes32,
|
|
174
|
-
) ->
|
|
174
|
+
) -> list[Coin]:
|
|
175
175
|
output_coins = []
|
|
176
176
|
for cvp in conditions_dict.get(ConditionOpcode.CREATE_COIN, []):
|
|
177
177
|
puzzle_hash, amount_bin = cvp.vars[0], cvp.vars[1]
|
|
@@ -183,8 +183,8 @@ def created_outputs_for_conditions_dict(
|
|
|
183
183
|
|
|
184
184
|
def conditions_dict_for_solution(
|
|
185
185
|
puzzle_reveal: Union[Program, SerializedProgram], solution: Union[Program, SerializedProgram], max_cost: int
|
|
186
|
-
) ->
|
|
187
|
-
conditions_dict:
|
|
186
|
+
) -> dict[ConditionOpcode, list[ConditionWithArgs]]:
|
|
187
|
+
conditions_dict: dict[ConditionOpcode, list[ConditionWithArgs]] = {}
|
|
188
188
|
for cvp in conditions_for_solution(puzzle_reveal, solution, max_cost):
|
|
189
189
|
conditions_dict.setdefault(cvp.opcode, list()).append(cvp)
|
|
190
190
|
return conditions_dict
|
|
@@ -192,10 +192,10 @@ def conditions_dict_for_solution(
|
|
|
192
192
|
|
|
193
193
|
def conditions_for_solution(
|
|
194
194
|
puzzle_reveal: Union[Program, SerializedProgram], solution: Union[Program, SerializedProgram], max_cost: int
|
|
195
|
-
) ->
|
|
195
|
+
) -> list[ConditionWithArgs]:
|
|
196
196
|
# get the standard script for a puzzle hash and feed in the solution
|
|
197
197
|
try:
|
|
198
|
-
|
|
198
|
+
_cost, r = puzzle_reveal.run_with_cost(max_cost, solution)
|
|
199
199
|
return parse_sexp_to_conditions(r)
|
|
200
200
|
except Program.EvalError as e:
|
|
201
201
|
raise ConsensusError(Err.SEXP_ERROR, [str(e)]) from e
|
chia/util/config.py
CHANGED
|
@@ -10,8 +10,9 @@ import sys
|
|
|
10
10
|
import tempfile
|
|
11
11
|
import time
|
|
12
12
|
import traceback
|
|
13
|
+
from collections.abc import Iterator
|
|
13
14
|
from pathlib import Path
|
|
14
|
-
from typing import Any, Callable,
|
|
15
|
+
from typing import Any, Callable, Optional, Union, cast
|
|
15
16
|
|
|
16
17
|
import importlib_resources
|
|
17
18
|
import yaml
|
|
@@ -30,7 +31,7 @@ def initial_config_file(filename: Union[str, Path]) -> str:
|
|
|
30
31
|
return contents
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
def create_default_chia_config(root_path: Path, filenames:
|
|
34
|
+
def create_default_chia_config(root_path: Path, filenames: list[str] = ["config.yaml"]) -> None:
|
|
34
35
|
for filename in filenames:
|
|
35
36
|
default_config_file_data: str = initial_config_file(filename)
|
|
36
37
|
path: Path = config_path_for_filename(root_path, filename)
|
|
@@ -66,7 +67,7 @@ def lock_and_load_config(
|
|
|
66
67
|
root_path: Path,
|
|
67
68
|
filename: Union[str, Path],
|
|
68
69
|
fill_missing_services: bool = False,
|
|
69
|
-
) -> Iterator[
|
|
70
|
+
) -> Iterator[dict[str, Any]]:
|
|
70
71
|
with lock_config(root_path=root_path, filename=filename):
|
|
71
72
|
config = _load_config_maybe_locked(
|
|
72
73
|
root_path=root_path,
|
|
@@ -96,7 +97,7 @@ def load_config(
|
|
|
96
97
|
sub_config: Optional[str] = None,
|
|
97
98
|
exit_on_error: bool = True,
|
|
98
99
|
fill_missing_services: bool = False,
|
|
99
|
-
) ->
|
|
100
|
+
) -> dict[str, Any]:
|
|
100
101
|
return _load_config_maybe_locked(
|
|
101
102
|
root_path=root_path,
|
|
102
103
|
filename=filename,
|
|
@@ -114,7 +115,7 @@ def _load_config_maybe_locked(
|
|
|
114
115
|
exit_on_error: bool = True,
|
|
115
116
|
acquire_lock: bool = True,
|
|
116
117
|
fill_missing_services: bool = False,
|
|
117
|
-
) ->
|
|
118
|
+
) -> dict[str, Any]:
|
|
118
119
|
# This must be called under an acquired config lock, or acquire_lock should be True
|
|
119
120
|
|
|
120
121
|
path = config_path_for_filename(root_path, filename)
|
|
@@ -130,7 +131,7 @@ def _load_config_maybe_locked(
|
|
|
130
131
|
for i in range(10):
|
|
131
132
|
try:
|
|
132
133
|
# at least we intend it to be this type
|
|
133
|
-
r:
|
|
134
|
+
r: dict[str, Any]
|
|
134
135
|
with contextlib.ExitStack() as exit_stack:
|
|
135
136
|
if acquire_lock:
|
|
136
137
|
exit_stack.enter_context(lock_config(root_path, filename))
|
|
@@ -143,7 +144,7 @@ def _load_config_maybe_locked(
|
|
|
143
144
|
if fill_missing_services:
|
|
144
145
|
r.update(load_defaults_for_missing_services(config=r, config_name=path.name))
|
|
145
146
|
if sub_config is not None:
|
|
146
|
-
r = cast(
|
|
147
|
+
r = cast(dict[str, Any], r.get(sub_config))
|
|
147
148
|
return r
|
|
148
149
|
except Exception as e:
|
|
149
150
|
tb = traceback.format_exc()
|
|
@@ -157,7 +158,7 @@ def load_config_cli(
|
|
|
157
158
|
filename: str,
|
|
158
159
|
sub_config: Optional[str] = None,
|
|
159
160
|
fill_missing_services: bool = False,
|
|
160
|
-
) ->
|
|
161
|
+
) -> dict[str, Any]:
|
|
161
162
|
"""
|
|
162
163
|
Loads configuration from the specified filename, in the config directory,
|
|
163
164
|
and then overrides any properties using the passed in command line arguments.
|
|
@@ -182,7 +183,7 @@ def load_config_cli(
|
|
|
182
183
|
return unflatten_properties(flattened_props)
|
|
183
184
|
|
|
184
185
|
|
|
185
|
-
def flatten_properties(config:
|
|
186
|
+
def flatten_properties(config: dict[str, Any]) -> dict[str, Any]:
|
|
186
187
|
properties = {}
|
|
187
188
|
for key, value in config.items():
|
|
188
189
|
if type(value) is dict:
|
|
@@ -193,8 +194,8 @@ def flatten_properties(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
193
194
|
return properties
|
|
194
195
|
|
|
195
196
|
|
|
196
|
-
def unflatten_properties(config:
|
|
197
|
-
properties:
|
|
197
|
+
def unflatten_properties(config: dict[str, Any]) -> dict[str, Any]:
|
|
198
|
+
properties: dict[str, Any] = {}
|
|
198
199
|
for key, value in config.items():
|
|
199
200
|
if "." in key:
|
|
200
201
|
add_property(properties, key, value)
|
|
@@ -203,7 +204,7 @@ def unflatten_properties(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
203
204
|
return properties
|
|
204
205
|
|
|
205
206
|
|
|
206
|
-
def add_property(d:
|
|
207
|
+
def add_property(d: dict[str, Any], partial_key: str, value: Any) -> None:
|
|
207
208
|
if "." not in partial_key: # root of dict
|
|
208
209
|
d[partial_key] = value
|
|
209
210
|
else:
|
|
@@ -220,15 +221,15 @@ def str2bool(v: Union[str, bool]) -> bool:
|
|
|
220
221
|
# Source from https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
|
|
221
222
|
if isinstance(v, bool):
|
|
222
223
|
return v
|
|
223
|
-
if v.lower() in
|
|
224
|
+
if v.lower() in {"yes", "true", "True", "t", "y", "1"}:
|
|
224
225
|
return True
|
|
225
|
-
elif v.lower() in
|
|
226
|
+
elif v.lower() in {"no", "false", "False", "f", "n", "0"}:
|
|
226
227
|
return False
|
|
227
228
|
else:
|
|
228
229
|
raise argparse.ArgumentTypeError("Boolean value expected.")
|
|
229
230
|
|
|
230
231
|
|
|
231
|
-
def traverse_dict(d:
|
|
232
|
+
def traverse_dict(d: dict[str, Any], key_path: str) -> Any:
|
|
232
233
|
"""
|
|
233
234
|
Traverse nested dictionaries to find the element pointed-to by key_path.
|
|
234
235
|
Key path components are separated by a ':' e.g.
|
|
@@ -256,7 +257,7 @@ def traverse_dict(d: Dict[str, Any], key_path: str) -> Any:
|
|
|
256
257
|
|
|
257
258
|
method_strings = Literal["default", "python_default", "fork", "forkserver", "spawn"]
|
|
258
259
|
method_values = Optional[Literal["fork", "forkserver", "spawn"]]
|
|
259
|
-
start_methods:
|
|
260
|
+
start_methods: dict[method_strings, method_values] = {
|
|
260
261
|
"default": None,
|
|
261
262
|
"python_default": None,
|
|
262
263
|
"fork": "fork",
|
|
@@ -266,7 +267,7 @@ start_methods: Dict[method_strings, method_values] = {
|
|
|
266
267
|
|
|
267
268
|
|
|
268
269
|
def process_config_start_method(
|
|
269
|
-
config:
|
|
270
|
+
config: dict[str, Any],
|
|
270
271
|
log: logging.Logger,
|
|
271
272
|
) -> method_values:
|
|
272
273
|
from_config: object = config.get("multiprocessing_start_method")
|
|
@@ -290,7 +291,7 @@ def process_config_start_method(
|
|
|
290
291
|
return processed_method
|
|
291
292
|
|
|
292
293
|
|
|
293
|
-
def override_config(config:
|
|
294
|
+
def override_config(config: dict[str, Any], config_overrides: Optional[dict[str, Any]]) -> dict[str, Any]:
|
|
294
295
|
new_config = copy.deepcopy(config)
|
|
295
296
|
if config_overrides is None:
|
|
296
297
|
return new_config
|
|
@@ -299,13 +300,13 @@ def override_config(config: Dict[str, Any], config_overrides: Optional[Dict[str,
|
|
|
299
300
|
return new_config
|
|
300
301
|
|
|
301
302
|
|
|
302
|
-
def selected_network_address_prefix(config:
|
|
303
|
+
def selected_network_address_prefix(config: dict[str, Any]) -> str:
|
|
303
304
|
# we intend this to be a str at least
|
|
304
305
|
address_prefix: str = config["network_overrides"]["config"][config["selected_network"]]["address_prefix"]
|
|
305
306
|
return address_prefix
|
|
306
307
|
|
|
307
308
|
|
|
308
|
-
def load_defaults_for_missing_services(config:
|
|
309
|
+
def load_defaults_for_missing_services(config: dict[str, Any], config_name: str) -> dict[str, Any]:
|
|
309
310
|
services = ["data_layer"]
|
|
310
311
|
missing_services = [service for service in services if service not in config]
|
|
311
312
|
defaulted = {}
|
|
@@ -331,16 +332,16 @@ def load_defaults_for_missing_services(config: Dict[str, Any], config_name: str)
|
|
|
331
332
|
return defaulted
|
|
332
333
|
|
|
333
334
|
|
|
334
|
-
PEER_INFO_MAPPING:
|
|
335
|
+
PEER_INFO_MAPPING: dict[NodeType, str] = {
|
|
335
336
|
NodeType.FULL_NODE: "full_node_peer",
|
|
336
337
|
NodeType.FARMER: "farmer_peer",
|
|
337
338
|
}
|
|
338
339
|
|
|
339
340
|
|
|
340
|
-
def get_unresolved_peer_infos(service_config:
|
|
341
|
+
def get_unresolved_peer_infos(service_config: dict[str, Any], peer_type: NodeType) -> set[UnresolvedPeerInfo]:
|
|
341
342
|
peer_info_key = PEER_INFO_MAPPING[peer_type]
|
|
342
|
-
peer_infos:
|
|
343
|
-
peer_info: Optional[
|
|
343
|
+
peer_infos: list[dict[str, Any]] = service_config.get(f"{peer_info_key}s", [])
|
|
344
|
+
peer_info: Optional[dict[str, Any]] = service_config.get(peer_info_key)
|
|
344
345
|
if peer_info is not None:
|
|
345
346
|
peer_infos.append(peer_info)
|
|
346
347
|
|
|
@@ -348,7 +349,7 @@ def get_unresolved_peer_infos(service_config: Dict[str, Any], peer_type: NodeTyp
|
|
|
348
349
|
|
|
349
350
|
|
|
350
351
|
def set_peer_info(
|
|
351
|
-
service_config:
|
|
352
|
+
service_config: dict[str, Any],
|
|
352
353
|
peer_type: NodeType,
|
|
353
354
|
peer_host: Optional[str] = None,
|
|
354
355
|
peer_port: Optional[int] = None,
|
chia/util/cpu.py
CHANGED
chia/util/db_synchronous.py
CHANGED
chia/util/db_version.py
CHANGED
chia/util/db_wrapper.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Package: utils
|
|
2
|
+
|
|
1
3
|
from __future__ import annotations
|
|
2
4
|
|
|
3
5
|
import asyncio
|
|
@@ -6,10 +8,11 @@ import functools
|
|
|
6
8
|
import secrets
|
|
7
9
|
import sqlite3
|
|
8
10
|
import sys
|
|
11
|
+
from collections.abc import AsyncIterator, Iterable
|
|
9
12
|
from dataclasses import dataclass, field
|
|
10
13
|
from datetime import datetime
|
|
11
14
|
from pathlib import Path
|
|
12
|
-
from typing import Any,
|
|
15
|
+
from typing import Any, Optional, TextIO, Union
|
|
13
16
|
|
|
14
17
|
import aiosqlite
|
|
15
18
|
import anyio
|
|
@@ -29,8 +32,8 @@ class DBWrapperError(Exception):
|
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
class ForeignKeyError(DBWrapperError):
|
|
32
|
-
def __init__(self, violations: Iterable[Union[aiosqlite.Row,
|
|
33
|
-
self.violations:
|
|
35
|
+
def __init__(self, violations: Iterable[Union[aiosqlite.Row, tuple[str, object, str, object]]]) -> None:
|
|
36
|
+
self.violations: list[dict[str, object]] = []
|
|
34
37
|
|
|
35
38
|
for violation in violations:
|
|
36
39
|
if isinstance(violation, tuple):
|
|
@@ -71,7 +74,8 @@ async def _create_connection(
|
|
|
71
74
|
log_file: Optional[TextIO] = None,
|
|
72
75
|
name: Optional[str] = None,
|
|
73
76
|
) -> aiosqlite.Connection:
|
|
74
|
-
|
|
77
|
+
# To avoid https://github.com/python/cpython/issues/118172
|
|
78
|
+
connection = await aiosqlite.connect(database=database, uri=uri, cached_statements=0)
|
|
75
79
|
|
|
76
80
|
if log_file is not None:
|
|
77
81
|
await connection.set_trace_callback(functools.partial(sql_trace_callback, file=log_file, name=name))
|
|
@@ -111,8 +115,7 @@ def get_host_parameter_limit() -> int:
|
|
|
111
115
|
if sys.version_info >= (3, 11):
|
|
112
116
|
connection = sqlite3.connect(":memory:")
|
|
113
117
|
|
|
114
|
-
|
|
115
|
-
limit_number = sqlite3.SQLITE_LIMIT_VARIABLE_NUMBER # pylint: disable=E1101
|
|
118
|
+
limit_number = sqlite3.SQLITE_LIMIT_VARIABLE_NUMBER
|
|
116
119
|
host_parameter_limit = connection.getlimit(limit_number)
|
|
117
120
|
else:
|
|
118
121
|
# guessing based on defaults, seems you can't query
|
|
@@ -136,7 +139,7 @@ class DBWrapper2:
|
|
|
136
139
|
_lock: asyncio.Lock = field(default_factory=asyncio.Lock)
|
|
137
140
|
_read_connections: asyncio.Queue[aiosqlite.Connection] = field(default_factory=asyncio.Queue)
|
|
138
141
|
_num_read_connections: int = 0
|
|
139
|
-
_in_use:
|
|
142
|
+
_in_use: dict[asyncio.Task[object], aiosqlite.Connection] = field(default_factory=dict)
|
|
140
143
|
_current_writer: Optional[asyncio.Task[object]] = None
|
|
141
144
|
_savepoint_name: int = 0
|
|
142
145
|
|
|
@@ -160,7 +163,7 @@ class DBWrapper2:
|
|
|
160
163
|
journal_mode: str = "WAL",
|
|
161
164
|
synchronous: Optional[str] = None,
|
|
162
165
|
foreign_keys: Optional[bool] = None,
|
|
163
|
-
row_factory: Optional[
|
|
166
|
+
row_factory: Optional[type[aiosqlite.Row]] = None,
|
|
164
167
|
) -> AsyncIterator[DBWrapper2]:
|
|
165
168
|
if foreign_keys is None:
|
|
166
169
|
foreign_keys = False
|
|
@@ -217,7 +220,7 @@ class DBWrapper2:
|
|
|
217
220
|
journal_mode: str = "WAL",
|
|
218
221
|
synchronous: Optional[str] = None,
|
|
219
222
|
foreign_keys: bool = False,
|
|
220
|
-
row_factory: Optional[
|
|
223
|
+
row_factory: Optional[type[aiosqlite.Row]] = None,
|
|
221
224
|
) -> DBWrapper2:
|
|
222
225
|
# WARNING: please use .managed() instead
|
|
223
226
|
if log_path is None:
|
|
@@ -270,7 +273,7 @@ class DBWrapper2:
|
|
|
270
273
|
await self._write_connection.execute(f"SAVEPOINT {name}")
|
|
271
274
|
try:
|
|
272
275
|
yield
|
|
273
|
-
except:
|
|
276
|
+
except:
|
|
274
277
|
await self._write_connection.execute(f"ROLLBACK TO {name}")
|
|
275
278
|
raise
|
|
276
279
|
finally:
|