pub fn read_from_db(db: &KeyValueDB, column: Option<u32>, prefix: &[u8]) -> error::Result<Self> {
		let mut storage = BTreeMap::new();

		for (key, value) in db.iter_from_prefix(column, prefix) {
			if !key.starts_with(prefix) { break }
			let raw_hash = &mut &key[prefix.len()..];
			let hash = match Decode::decode(raw_hash) {
				Some(hash) => hash,
				None => return Err(error::ErrorKind::Backend("Error decoding hash".into()).into()),
			};
			let number = match Decode::decode(&mut &value[..]) {
				Some(number) => number,
				None => return Err(error::ErrorKind::Backend("Error decoding number".into()).into()),
			};
			storage.entry(Reverse(number)).or_insert_with(Vec::new).push(hash);
		}
		Ok(Self {
			storage,
			pending_added: Vec::new(),
			pending_removed: Vec::new(),
		})
	}
/// Read the leaf list from the DB, using given prefix for keys.
Read the leaf list from the DB, using given prefix for keys.
Read the leaf list from the DB using given prefix for keys .
pub fn read_from_db(db: &KeyValueDB, column: Option<u32>, prefix: &[u8]) -> error::Result<Self> {
		let mut storage = BTreeMap::new();
		for (key, value) in db.iter_from_prefix(column, prefix) {
			if !key.starts_with(prefix) { break }
			let raw_hash = &mut &key[prefix.len()..];
			let hash = match Decode::decode(raw_hash) {
				Some(hash) => hash,
				None => return Err(error::ErrorKind::Backend("Error decoding hash".into()).into()),
			};
			let number = match Decode::decode(&mut &value[..]) {
				Some(number) => number,
				None => return Err(error::ErrorKind::Backend("Error decoding number".into()).into()),
			};
			storage.entry(Reverse(number)).or_insert_with(Vec::new).push(hash);
		}
		Ok(Self {
			storage,
			pending_added: Vec::new(),
			pending_removed: Vec::new(),
		})
	}
pub fn read_from_db ( db : & KeyValueDB , column : Option < u32 > , prefix : & [ u8 ] ) -> error :: Result < Self > { let mut storage = BTreeMap :: new ( ) ; for ( key , value ) in db . iter_from_prefix ( column , prefix ) { if ! key . starts_with ( prefix ) { break } let raw_hash = & mut & key [ prefix . len ( ) .. ] ; let hash = match Decode :: decode ( raw_hash ) { Some ( hash ) => hash , None => return Err ( error :: ErrorKind :: Backend ( " " . into ( ) ) . into ( ) ) , } ; let number = match Decode :: decode ( & mut & value [ .. ] ) { Some ( number ) => number , None => return Err ( error :: ErrorKind :: Backend ( " " . into ( ) ) . into ( ) ) , } ; storage . entry ( Reverse ( number ) ) . or_insert_with ( Vec :: new ) . push ( hash ) ; } Ok ( Self { storage , pending_added : Vec :: new ( ) , pending_removed : Vec :: new ( ) , } ) }
Read the leaf list from the DB, using given prefix for keys.
Read the leaf list from the DB using given prefix for keys .
db
&KeyValueDB
column
Option<u32>
prefix
&[u8]
db
&KeyValueDB
column
Option<u32>
prefix
&[u8]