`Account::apply_patch` rejects full-state patches
- Lingua principale
- Rust
- Stelle
- 132
- Fork
- 167
- Merge medio
- 1g 23h
- PR unite (30g)
- 110
Descrizione
`Account::apply_patch` rejects a full-state `AccountPatch` (the kind produced by an account creating transaction), forcing callers to branch on `AccountPatch::is_full_state()` and reconstruct the account via `Account::try_from(&patch)` instead of applying the patch uniformly. This is a DX rough edge: consumers that maintain an in-memory account by applying successive patches need two code paths where one would be natural.
In the node's `network-monitor`, the monitor wallet is created in-memory and never separately deployed, so its *first* increment transaction doubles as the account-creation transaction. That transaction's patch is full-state (it carries the account code + full initial state), so `apply_patch` cannot be used and we must special-case it:
```rust
if account_patch.is_full_state() {
self.wallet_account = Account::try_from(account_patch)
.expect("full-state patch should convert to a valid account");
} else {
self.wallet_account
.apply_patch(account_patch)
.expect("successful tx should apply patch correctly");
}
Can the `is_full_state()` be absorbed into `apply_patch`?
Is there a reason a full-state patch can't be applied onto a nonce-0 empty account?
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.