snarkvm_ledger_debug/
iterators.rs

1// Copyright (C) 2019-2023 Aleo Systems Inc.
2// This file is part of the snarkVM library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7// http://www.apache.org/licenses/LICENSE-2.0
8
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use super::*;
16
17impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
18    /// Returns an iterator over the state roots, for all blocks in `self`.
19    pub fn state_roots(&self) -> impl '_ + Iterator<Item = Cow<'_, N::StateRoot>> {
20        self.vm.block_store().state_roots()
21    }
22
23    /// Returns an iterator over the puzzle commitments, for all blocks in `self`.
24    pub fn puzzle_commitments(&self) -> impl '_ + Iterator<Item = Cow<'_, PuzzleCommitment<N>>> {
25        self.vm.block_store().puzzle_commitments()
26    }
27
28    /* Transaction */
29
30    /// Returns an iterator over the program IDs, for all transactions in `self`.
31    pub fn program_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, ProgramID<N>>> {
32        self.vm.transaction_store().program_ids()
33    }
34
35    /// Returns an iterator over the programs, for all transactions in `self`.
36    pub fn programs(&self) -> impl '_ + Iterator<Item = Cow<'_, Program<N>>> {
37        self.vm.transaction_store().programs()
38    }
39
40    /// Returns an iterator over the transaction IDs, for all transactions in `self`.
41    pub fn transaction_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, N::TransactionID>> {
42        self.vm.transaction_store().transaction_ids()
43    }
44
45    /* Transition */
46
47    /// Returns an iterator over the transition IDs, for all transitions.
48    pub fn transition_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, N::TransitionID>> {
49        self.vm.transition_store().transition_ids()
50    }
51
52    /* Input */
53
54    /// Returns an iterator over the input IDs, for all transition inputs.
55    pub fn input_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> {
56        self.vm.transition_store().input_ids()
57    }
58
59    /// Returns an iterator over the serial numbers, for all transition inputs that are records.
60    pub fn serial_numbers(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> {
61        self.vm.transition_store().serial_numbers()
62    }
63
64    /// Returns an iterator over the tags, for all transition inputs that are records.
65    pub fn tags(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> {
66        self.vm.transition_store().tags()
67    }
68
69    /* Output */
70
71    /// Returns an iterator over the output IDs, for all transition outputs that are records.
72    pub fn output_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> {
73        self.vm.transition_store().output_ids()
74    }
75
76    /// Returns an iterator over the commitments, for all transition outputs that are records.
77    pub fn commitments(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> {
78        self.vm.transition_store().commitments()
79    }
80
81    /// Returns an iterator over the nonces, for all transition outputs that are records.
82    pub fn nonces(&self) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>> {
83        self.vm.transition_store().nonces()
84    }
85
86    /// Returns an iterator over the `(commitment, record)` pairs, for all transition outputs that are records.
87    pub fn records(&self) -> impl '_ + Iterator<Item = (Cow<'_, Field<N>>, Cow<'_, Record<N, Ciphertext<N>>>)> {
88        self.vm.transition_store().records()
89    }
90
91    /* Metadata */
92
93    /// Returns an iterator over the transition public keys, for all transactions.
94    pub fn transition_public_keys(&self) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>> {
95        self.vm.transition_store().tpks()
96    }
97}