Skip to content

Commit 02c6457

Browse files
committed
hashmap -> hashset
1 parent 6362307 commit 02c6457

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

testnet/stacks-node/src/nakamoto_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
use std::collections::HashMap;
16+
use std::collections::HashSet;
1717
use std::sync::mpsc::Receiver;
1818
use std::thread;
1919
use std::thread::JoinHandle;
@@ -48,7 +48,7 @@ const VRF_MOCK_MINER_KEY: u64 = 1;
4848

4949
pub const BLOCK_PROCESSOR_STACK_SIZE: usize = 32 * 1024 * 1024; // 32 MB
5050

51-
pub type BlockCommits = HashMap<Txid, ()>;
51+
pub type BlockCommits = HashSet<Txid>;
5252

5353
/// Node implementation for both miners and followers.
5454
/// This struct is used to set up the node proper and launch the p2p thread and relayer thread.

testnet/stacks-node/src/nakamoto_node/relayer.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
use core::fmt;
17-
use std::collections::HashMap;
17+
use std::collections::HashSet;
1818
use std::sync::mpsc::{Receiver, RecvTimeoutError};
1919
use std::thread::JoinHandle;
2020
use std::time::{Duration, Instant};
@@ -194,7 +194,7 @@ impl RelayerThread {
194194
keychain,
195195
burnchain: runloop.get_burnchain(),
196196
last_vrf_key_burn_height: None,
197-
last_commits: HashMap::new(),
197+
last_commits: HashSet::new(),
198198
bitcoin_controller,
199199
event_dispatcher: runloop.get_event_dispatcher(),
200200
local_peer,
@@ -309,8 +309,7 @@ impl RelayerThread {
309309

310310
self.globals.set_last_sortition(sn.clone());
311311

312-
let won_sortition =
313-
sn.sortition && self.last_commits.remove(&sn.winning_block_txid).is_some();
312+
let won_sortition = sn.sortition && self.last_commits.remove(&sn.winning_block_txid);
314313

315314
info!(
316315
"Relayer: Process sortition";
@@ -692,7 +691,7 @@ impl RelayerThread {
692691
"txid" => %txid,
693692
);
694693

695-
self.last_commits.insert(txid, ());
694+
self.last_commits.insert(txid);
696695
self.last_committed = Some((
697696
last_committed_at,
698697
StacksBlockId::new(&tenure_start_ch, &tenure_start_bh),

0 commit comments

Comments
 (0)