LiteSVM / litesvm

Apache License 2.0
91 stars 17 forks source link

Allow the user to configure transaction history capacity #37

Closed Aursen closed 6 months ago

Aursen commented 6 months ago

close #22

kevinheavey commented 6 months ago

Let's change add_new_transaction to this:

    pub fn add_new_transaction(&mut self, signature: Signature, meta: TransactionMetadata) {
        let capacity = self.0.capacity();
        if capacity != 0 {
            if self.0.len() == capacity {
                self.0.shift_remove_index(0);
            }
            self.0.insert(signature, meta);
        }
    }

This checks the len against the capacity which is no longer hard-coded to 500, and at the edge case where the capacity is 0 it doesn't add any transactions