message: fix: chunk queue contains_key
diff: @@ -8,12 +8,18 @@ use ckb_util::{shrink_to_fit, LinkedHashMap};
  const SHRINK_THRESHOLD: usize = 100;
  pub(crate) const DEFAULT_MAX_CHUNK_TRANSACTIONS: usize = 100;
  -#[derive(Debug, Clone)]
  +#[derive(Debug, Clone, Eq)]
  pub(crate) struct Entry {
  pub(crate) tx: TransactionView,
  pub(crate) remote: Option<(Cycle, PeerIndex)>,
  }
  +impl PartialEq for Entry {
  + fn eq(&self, other: &Entry) -> bool {
  + self.tx == other.tx
  + }
  +}
  +
  #[derive(Default)]
  pub(crate) struct ChunkQueue {
  inner: LinkedHashMap<ProposalShortId, Entry>,
  @@ -42,9 +48,13 @@ impl ChunkQueue {
  self.len() > DEFAULT_MAX_CHUNK_TRANSACTIONS
  }
  - #[allow(dead_code)]
  pub fn contains_key(&self, id: &ProposalShortId) -> bool {
  - self.inner.contains_key(id)
  + self.front
  + .as_ref()
  + .map(|e| e.tx.proposal_short_id())
  + .as_ref()
  + == Some(id)
  + || self.inner.contains_key(id)
  }
  pub fn shrink_to_fit(&mut self) {
  @@ -85,7 +95,7 @@ impl ChunkQueue {
  return;
  }
  - if self.inner.contains_key(&tx.proposal_short_id()) {
  + if self.contains_key(&tx.proposal_short_id()) {
  return;
  }
  @@ -102,7 +112,7 @@ impl ChunkQueue {
  ///
  /// If the queue did have this tx present, false is returned.
  pub fn add_tx(&mut self, tx: TransactionView) -> bool {
  - if self.inner.contains_key(&tx.proposal_short_id()) {
  + if self.contains_key(&tx.proposal_short_id()) {
  return false;
  }
  @@ -117,3 +127,28 @@ impl ChunkQueue {
  self.shrink_to_fit()
  }
  }
  +
  +#[cfg(test)]
  +mod tests {
  + use super::*;
  + use ckb_types::core::TransactionBuilder;
  +
  + #[test]
  + fn basic() {
  + let tx = TransactionBuilder::default().build();
  + let entry = Entry {
  + tx: tx.clone(),
  + remote: None,
  + };
  + let id = tx.proposal_short_id();
  + let mut queue = ChunkQueue::new();
  +
  + assert!(queue.add_tx(tx.clone()));
  + assert_eq!(queue.pop_front().as_ref(), Some(&entry));
  + assert!(queue.contains_key(&id));
  + assert!(!queue.add_tx(tx));
  +
  + queue.clean_front();
  + assert!(!queue.contains_key(&id));
  + }
  +}
  