mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-24 02:24:23 -05:00
Identify DL singletons in determine_coin_type (and save computation) (#21271)
This commit is contained in:
@@ -33,6 +33,7 @@ from chia.wallet.db_wallet.db_wallet_puzzles import (
|
||||
ACS_MU,
|
||||
ACS_MU_PH,
|
||||
GRAFTROOT_DL_OFFERS,
|
||||
MIRROR_PUZZLE_HASH,
|
||||
create_graftroot_offer_puz,
|
||||
create_host_fullpuz,
|
||||
create_host_layer_puzzle,
|
||||
@@ -52,7 +53,7 @@ from chia.wallet.transaction_record import TransactionRecord
|
||||
from chia.wallet.util.compute_additions import compute_additions
|
||||
from chia.wallet.util.merkle_utils import _simplify_merkle_proof
|
||||
from chia.wallet.util.wallet_sync_utils import fetch_coin_spend, fetch_coin_spend_for_coin_state
|
||||
from chia.wallet.util.wallet_types import WalletType
|
||||
from chia.wallet.util.wallet_types import WalletIdentifier, WalletType
|
||||
from chia.wallet.wallet import Wallet
|
||||
from chia.wallet.wallet_action_scope import WalletActionScope
|
||||
from chia.wallet.wallet_coin_record import WalletCoinRecord
|
||||
@@ -894,6 +895,19 @@ class DataLayerWallet:
|
||||
raise e # raise the error if we've tried all peers
|
||||
continue # try some other peers, maybe someone has it
|
||||
|
||||
@classmethod
|
||||
async def identify(cls, wallet_state_manager: WalletStateManager, coin_state: CoinState) -> WalletIdentifier | None:
|
||||
try:
|
||||
dl_wallet = await wallet_state_manager.get_dl_wallet()
|
||||
except ValueError:
|
||||
return None
|
||||
if (
|
||||
coin_state.coin.puzzle_hash == MIRROR_PUZZLE_HASH
|
||||
or await dl_wallet.get_singleton_record(coin_state.coin.name()) is not None
|
||||
):
|
||||
return WalletIdentifier.create(dl_wallet)
|
||||
return None
|
||||
|
||||
###########
|
||||
# UTILITY #
|
||||
###########
|
||||
|
||||
@@ -55,7 +55,6 @@ from chia.wallet.conditions import (
|
||||
CreateCoin,
|
||||
parse_timelock_info,
|
||||
)
|
||||
from chia.wallet.db_wallet.db_wallet_puzzles import MIRROR_PUZZLE_HASH
|
||||
from chia.wallet.derivation_record import DerivationRecord
|
||||
from chia.wallet.derive_keys import (
|
||||
MAX_POOL_WALLETS,
|
||||
@@ -921,6 +920,10 @@ class WalletStateManager:
|
||||
):
|
||||
return None, None
|
||||
|
||||
dl_identification = await DataLayerWallet.identify(self, coin_state)
|
||||
if dl_identification is not None:
|
||||
return dl_identification, None
|
||||
|
||||
response: list[CoinState] = await self.wallet_node.get_coin_state(
|
||||
[coin_state.coin.parent_coin_info], peer=peer, fork_height=fork_height
|
||||
)
|
||||
@@ -1704,16 +1707,6 @@ class WalletStateManager:
|
||||
wallet_identifier = WalletIdentifier(uint32(local_record.wallet_id), local_record.wallet_type)
|
||||
elif coin_state.created_height is not None:
|
||||
wallet_identifier, coin_data = await self.determine_coin_type(peer, coin_state, fork_height)
|
||||
try:
|
||||
dl_wallet = await self.get_dl_wallet()
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
if (
|
||||
await dl_wallet.get_singleton_record(coin_name) is not None
|
||||
or coin_state.coin.puzzle_hash == MIRROR_PUZZLE_HASH
|
||||
):
|
||||
wallet_identifier = WalletIdentifier.create(dl_wallet)
|
||||
|
||||
# If this coin was previously only stored as an "interest-only" record (REMOTE),
|
||||
# but we now recognize it as belonging to a real wallet, treat it as a new coin so wallet-specific
|
||||
|
||||
Reference in New Issue
Block a user