storage_interface/state_view.rs
1// Copyright (c) The Diem Core Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4// Copyright 2021 Conflux Foundation. All rights reserved.
5// Conflux is free software and distributed under GNU General Public License.
6// See http://www.gnu.org/licenses/
7
8use diem_state_view::{StateView, StateViewId};
9use diem_types::term_state::PosState;
10
11/// `VerifiedStateView` is a snapshot of the global state for PoS execution.
12///
13/// In Conflux PoS, the VM (`PosVM`) reads state exclusively through
14/// `pos_state()`.
15pub struct VerifiedStateView {
16 id: StateViewId,
17 pos_state: PosState,
18}
19
20impl VerifiedStateView {
21 pub fn new(id: StateViewId, pos_state: PosState) -> Self {
22 Self { id, pos_state }
23 }
24}
25
26impl StateView for VerifiedStateView {
27 fn id(&self) -> StateViewId { self.id }
28
29 fn pos_state(&self) -> &PosState { &self.pos_state }
30}