pub fn trigger(&mut self, hash: &Block::Hash, changeset: impl Iterator<Item=(Vec<u8>, Option<Vec<u8>>)>) {
		let has_wildcard = !self.wildcard_listeners.is_empty();

		// early exit if no listeners
		if !has_wildcard && self.listeners.is_empty() {
			return;
		}

		let mut subscribers = self.wildcard_listeners.clone();
		let mut changes = Vec::new();

		// Collect subscribers and changes
		for (k, v) in changeset {
			let k = StorageKey(k);
			let listeners = self.listeners.get(&k);

			if let Some(ref listeners) = listeners {
				subscribers.extend(listeners.iter());
			}

			if has_wildcard || listeners.is_some() {
				changes.push((k, v.map(StorageData)));
			}
		}

		// Don't send empty notifications
		if changes.is_empty() {
			return;
		}

		let changes = Arc::new(changes);
		// Trigger the events
		for subscriber in subscribers {
			let should_remove = {
				let &(ref sink, ref filter) = self.sinks.get(&subscriber)
					.expect("subscribers returned from self.listeners are always in self.sinks; qed");
				sink.unbounded_send((hash.clone(), StorageChangeSet {
					changes: changes.clone(),
					filter: filter.clone(),
				})).is_err()
			};

			if should_remove {
				self.remove_subscriber(subscriber);
			}
		}
	}
/// Trigger notification to all listeners.
///
/// Note the changes are going to be filtered by listener's filter key.
/// In fact no event might be sent if clients are not interested in the changes.
Trigger notification to all listeners.
Note the changes are going to be filtered by listener's filter key.
In fact no event might be sent if clients are not interested in the changes.
Trigger notification to all listeners . Note the changes are going to be filtered by listener ' s filter key . In fact no event might be sent if clients are not interested in the changes .
pub fn trigger(&mut self, hash: &Block::Hash, changeset: impl Iterator<Item=(Vec<u8>, Option<Vec<u8>>)>) {
		let has_wildcard = !self.wildcard_listeners.is_empty();
		// early exit if no listeners
		if !has_wildcard && self.listeners.is_empty() {
			return;
		}
		let mut subscribers = self.wildcard_listeners.clone();
		let mut changes = Vec::new();
		// Collect subscribers and changes
		for (k, v) in changeset {
			let k = StorageKey(k);
			let listeners = self.listeners.get(&k);
			if let Some(ref listeners) = listeners {
				subscribers.extend(listeners.iter());
			}
			if has_wildcard || listeners.is_some() {
				changes.push((k, v.map(StorageData)));
			}
		}
		// Don't send empty notifications
		if changes.is_empty() {
			return;
		}
		let changes = Arc::new(changes);
		// Trigger the events
		for subscriber in subscribers {
			let should_remove = {
				let &(ref sink, ref filter) = self.sinks.get(&subscriber)
					.expect("subscribers returned from self.listeners are always in self.sinks; qed");
				sink.unbounded_send((hash.clone(), StorageChangeSet {
					changes: changes.clone(),
					filter: filter.clone(),
				})).is_err()
			};
			if should_remove {
				self.remove_subscriber(subscriber);
			}
		}
	}
pub fn trigger ( & mut self , hash : & Block :: Hash , changeset : impl Iterator < Item = ( Vec < u8 > , Option < Vec < u8 > > ) > ) { let has_wildcard = ! self . wildcard_listeners . is_empty ( ) ; // early exit if no listeners if ! has_wildcard && self . listeners . is_empty ( ) { return ; } let mut subscribers = self . wildcard_listeners . clone ( ) ; let mut changes = Vec :: new ( ) ; // Collect subscribers and changes for ( k , v ) in changeset { let k = StorageKey ( k ) ; let listeners = self . listeners . get ( & k ) ; if let Some ( ref listeners ) = listeners { subscribers . extend ( listeners . iter ( ) ) ; } if has_wildcard || listeners . is_some ( ) { changes . push ( ( k , v . map ( StorageData ) ) ) ; } } // Don't send empty notifications if changes . is_empty ( ) { return ; } let changes = Arc :: new ( changes ) ; // Trigger the events for subscriber in subscribers { let should_remove = { let & ( ref sink , ref filter ) = self . sinks . get ( & subscriber ) . expect ( " " ) ; sink . unbounded_send ( ( hash . clone ( ) , StorageChangeSet { changes : changes . clone ( ) , filter : filter . clone ( ) , } ) ) . is_err ( ) } ; if should_remove { self . remove_subscriber ( subscriber ) ; } } }
Trigger notification to all listeners.
Trigger notification to all listeners .
&mut self
hash
&Block::Hash
changeset
impl Iterator<Item=(Vec<u8>, Option<Vec<u8>>)>
&mut self
hash
&Block::Hash
changeset
impl Iterator<Item=(Vec<u8>, Option<Vec<u8>>)>