rustledger_plugin/native/plugins/
no_duplicates.rs1use crate::types::{PluginInput, PluginOutput};
10
11use super::super::NativePlugin;
12
13pub struct NoDuplicatesPlugin;
15
16impl NativePlugin for NoDuplicatesPlugin {
17 fn name(&self) -> &'static str {
18 "noduplicates"
19 }
20
21 fn description(&self) -> &'static str {
22 "Hash-based duplicate transaction detection"
23 }
24
25 fn process(&self, input: PluginInput) -> PluginOutput {
26 let duplicates = rustledger_ops::dedup::find_structural_duplicates(&input.directives);
27 let errors = duplicates
28 .iter()
29 .map(rustledger_ops::dedup::StructuralDuplicate::to_plugin_error)
30 .collect();
31
32 PluginOutput {
33 directives: input.directives,
34 errors,
35 }
36 }
37}