1
- use std:: { collections:: HashMap , sync:: Arc } ;
1
+ use std:: {
2
+ collections:: { BTreeMap , HashMap } ,
3
+ sync:: Arc ,
4
+ } ;
2
5
3
6
use sqlite:: { Connection , Value } ;
4
7
@@ -453,8 +456,8 @@ impl StoreAdapter for SignerRegistrationStoreAdapter {
453
456
. collect :: < Vec < _ > > ( )
454
457
. into_iter ( )
455
458
. rev ( ) ;
456
- let signer_with_stake_by_epoch: HashMap < Self :: Key , Self :: Record > = cursor. fold (
457
- HashMap :: < Self :: Key , Self :: Record > :: new ( ) ,
459
+ let signer_with_stake_by_epoch: BTreeMap < Self :: Key , Self :: Record > = cursor. fold (
460
+ BTreeMap :: < Self :: Key , Self :: Record > :: new ( ) ,
458
461
|mut acc, signer_registration_record| {
459
462
let epoch = signer_registration_record. epoch_setting_id ;
460
463
let mut signer_with_stakes: Self :: Record =
@@ -473,6 +476,7 @@ impl StoreAdapter for SignerRegistrationStoreAdapter {
473
476
) ;
474
477
Ok ( signer_with_stake_by_epoch
475
478
. into_iter ( )
479
+ . rev ( )
476
480
. take ( how_many)
477
481
. collect ( ) )
478
482
}
@@ -839,7 +843,7 @@ mod tests {
839
843
async fn test_store_adapter ( ) {
840
844
let fixture = MithrilFixtureBuilder :: default ( ) . with_signers ( 5 ) . build ( ) ;
841
845
let signer_with_stakes = fixture. signers_with_stake ( ) ;
842
- let signer_with_stakes_by_epoch: Vec < ( Epoch , HashMap < PartyId , SignerWithStake > ) > = ( 0 ..1 )
846
+ let signer_with_stakes_by_epoch: Vec < ( Epoch , HashMap < PartyId , SignerWithStake > ) > = ( 0 ..5 )
843
847
. map ( |e| {
844
848
(
845
849
Epoch ( e) ,
0 commit comments