github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/sawtooth-core-master/validator/src/state/mod.rs (about) 1 /* 2 * Copyright 2018 Intel Corporation 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 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * ------------------------------------------------------------------------------ 16 */ 17 18 pub mod error; 19 pub mod identity_view; 20 pub mod merkle; 21 pub mod merkle_ffi; 22 pub mod settings_view; 23 pub mod state_pruning_manager; 24 25 use state::error::StateDatabaseError; 26 27 pub trait StateReader { 28 /// Returns true if the given address exists in State; false, otherwise. 29 /// 30 /// Will return a StateDatabaseError if any errors occur while querying for 31 /// the existence of the given address. 32 fn contains(&self, address: &str) -> Result<bool, StateDatabaseError>; 33 34 /// Returns the data for a given address, if it exists. In the case where 35 /// the address exists, but has no data, it will return None. 36 /// 37 /// Will return an StateDatabaseError::NotFound, if the given address is not 38 /// in State. 39 fn get(&self, address: &str) -> Result<Option<Vec<u8>>, StateDatabaseError>; 40 41 /// A state value is considered a leaf if it has data stored at the address. 42 /// 43 /// Returns an iterator over address-value pairs in state. 44 /// 45 /// Returns Err if the prefix is invalid, or if any other database errors 46 /// occur while creating the iterator. 47 fn leaves( 48 &self, 49 prefix: Option<&str>, 50 ) -> Result< 51 Box<Iterator<Item = Result<(String, Vec<u8>), StateDatabaseError>>>, 52 StateDatabaseError, 53 >; 54 }