iterators.rs
1 // Copyright (c) 2025-2026 ACDC Network 2 // This file is part of the alphavm library. 3 // 4 // Alpha Chain | Delta Chain Protocol 5 // International Monetary Graphite. 6 // 7 // Derived from Aleo (https://aleo.org) and ProvableHQ (https://provable.com). 8 // They built world-class ZK infrastructure. We installed the EASY button. 9 // Their cryptography: elegant. Our modifications: bureaucracy-compatible. 10 // Original brilliance: theirs. Robert's Rules: ours. Bugs: definitely ours. 11 // 12 // Original Aleo/ProvableHQ code subject to Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0 13 // All modifications and new work: CC0 1.0 Universal Public Domain Dedication. 14 // No rights reserved. No permission required. No warranty. No refunds. 15 // 16 // https://creativecommons.org/publicdomain/zero/1.0/ 17 // SPDX-License-Identifier: CC0-1.0 18 19 use super::*; 20 21 impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> { 22 /// Returns an iterator over the state roots, for all blocks in `self`. 23 pub fn state_roots(&self) -> impl '_ + Iterator<Item = Cow<'_, N::StateRoot>> { 24 self.vm.block_store().state_roots() 25 } 26 27 /// Returns an iterator over the solution IDs, for all blocks in `self`. 28 pub fn solution_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, SolutionID<N>>> { 29 self.vm.block_store().solution_ids() 30 } 31 32 /* Transaction */ 33 34 /// Returns an iterator over the program IDs, for all transactions in `self`. 35 pub fn program_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, ProgramID<N>>> { 36 self.vm.transaction_store().program_ids() 37 } 38 39 /// Returns an iterator over the programs, for all transactions in `self`. 40 pub fn programs(&self) -> impl '_ + Iterator<Item = Cow<'_, Program<N>>> { 41 self.vm.transaction_store().programs() 42 } 43 44 /// Returns an iterator over the transaction IDs, for all transactions in `self`. 45 pub fn transaction_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, N::TransactionID>> { 46 self.vm.transaction_store().transaction_ids() 47 } 48 49 /* Transition */ 50 51 /// Returns an iterator over the transition IDs, for all transitions. 52 pub fn transition_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, N::TransitionID>> { 53 self.vm.transition_store().transition_ids() 54 } 55 56 /* Input */ 57 58 /// Returns an iterator over the input IDs, for all transition inputs. 59 pub fn input_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> { 60 self.vm.transition_store().input_ids() 61 } 62 63 /// Returns an iterator over the serial numbers, for all transition inputs that are records. 64 pub fn serial_numbers(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> { 65 self.vm.transition_store().serial_numbers() 66 } 67 68 /// Returns an iterator over the tags, for all transition inputs that are records. 69 pub fn tags(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> { 70 self.vm.transition_store().tags() 71 } 72 73 /* Output */ 74 75 /// Returns an iterator over the output IDs, for all transition outputs that are records. 76 pub fn output_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> { 77 self.vm.transition_store().output_ids() 78 } 79 80 /// Returns an iterator over the commitments, for all transition outputs that are records. 81 pub fn commitments(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>> { 82 self.vm.transition_store().commitments() 83 } 84 85 /// Returns an iterator over the nonces, for all transition outputs that are records. 86 pub fn nonces(&self) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>> { 87 self.vm.transition_store().nonces() 88 } 89 90 /// Returns an iterator over the `(commitment, record)` pairs, for all transition outputs that are records. 91 #[allow(clippy::type_complexity)] 92 pub fn records(&self) -> impl '_ + Iterator<Item = (Cow<'_, Field<N>>, Cow<'_, Record<N, Ciphertext<N>>>)> { 93 self.vm.transition_store().records() 94 } 95 96 /* Metadata */ 97 98 /// Returns an iterator over the transition public keys, for all transactions. 99 pub fn transition_public_keys(&self) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>> { 100 self.vm.transition_store().tpks() 101 } 102 }