Skip to content

Commit

Permalink
[mempool] Remove mutability from read only functions in indexes
Browse files Browse the repository at this point in the history
Remove mut from timeline_range in Transaction store

Fix formatting issue

Closes: aptos-labs#9515
  • Loading branch information
vss96 authored and bors-libra committed Oct 27, 2021
1 parent 3d98b1a commit 7a34778
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions mempool/src/core_mempool/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl TimelineIndex {

/// Read all transactions from the timeline since <timeline_id>.
pub(crate) fn read_timeline(
&mut self,
&self,
timeline_id: u64,
count: usize,
) -> Vec<(AccountAddress, u64)> {
Expand All @@ -233,11 +233,7 @@ impl TimelineIndex {
}

/// Read transactions from the timeline from `start_id` (exclusive) to `end_id` (inclusive).
pub(crate) fn timeline_range(
&mut self,
start_id: u64,
end_id: u64,
) -> Vec<(AccountAddress, u64)> {
pub(crate) fn timeline_range(&self, start_id: u64, end_id: u64) -> Vec<(AccountAddress, u64)> {
self.timeline
.range((Bound::Excluded(start_id), Bound::Included(end_id)))
.map(|(_idx, txn)| txn)
Expand Down Expand Up @@ -349,7 +345,7 @@ impl ParkingLotIndex {
}

/// Returns a random "non-ready" transaction (with highest sequence number for that account).
pub(crate) fn get_poppable(&mut self) -> Option<TxnPointer> {
pub(crate) fn get_poppable(&self) -> Option<TxnPointer> {
let mut rng = rand::thread_rng();
self.data
.choose(&mut rng)
Expand Down
2 changes: 1 addition & 1 deletion mempool/src/core_mempool/transaction_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl TransactionStore {
(batch, last_timeline_id)
}

pub(crate) fn timeline_range(&mut self, start_id: u64, end_id: u64) -> Vec<SignedTransaction> {
pub(crate) fn timeline_range(&self, start_id: u64, end_id: u64) -> Vec<SignedTransaction> {
self.timeline_index
.timeline_range(start_id, end_id)
.iter()
Expand Down

0 comments on commit 7a34778

Please sign in to comment.