`Account::apply_patch` rejects full-state patches
- 主要語言
- Rust
- 星號
- 132
- 分支
- 167
- 平均合併
- 1 天 23 小時
- 30 天內合併 PR
- 110
描述
`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?
貢獻指南
評估
這個 Issue 還沒有評估資料。