@@ -1096,7 +1096,10 @@ pub trait SortitionHandle {
1096
1096
/// descends from `key.1`
1097
1097
///
1098
1098
/// If it does, return the cached entry
1099
- fn descendancy_cache_get ( cache : & mut MutexGuard < ' _ , LruCache < ( SortitionId , BlockHeaderHash ) , bool > > , key : & ( SortitionId , BlockHeaderHash ) ) -> Option < bool > {
1099
+ fn descendancy_cache_get (
1100
+ cache : & mut MutexGuard < ' _ , LruCache < ( SortitionId , BlockHeaderHash ) , bool > > ,
1101
+ key : & ( SortitionId , BlockHeaderHash ) ,
1102
+ ) -> Option < bool > {
1100
1103
match cache. get ( key) {
1101
1104
Ok ( result) => result,
1102
1105
// cache is broken, create a new one
@@ -1110,7 +1113,11 @@ pub trait SortitionHandle {
1110
1113
1111
1114
/// Cache the result of the descendancy check on whether or not the winning block in `key.0`
1112
1115
/// descends from `key.1`
1113
- fn descendancy_cache_put ( cache : & mut MutexGuard < ' _ , LruCache < ( SortitionId , BlockHeaderHash ) , bool > > , key : ( SortitionId , BlockHeaderHash ) , is_descended : bool ) {
1116
+ fn descendancy_cache_put (
1117
+ cache : & mut MutexGuard < ' _ , LruCache < ( SortitionId , BlockHeaderHash ) , bool > > ,
1118
+ key : ( SortitionId , BlockHeaderHash ) ,
1119
+ is_descended : bool ,
1120
+ ) {
1114
1121
if let Err ( e) = cache. insert_clean ( key, is_descended) {
1115
1122
error ! ( "SortitionDB's descendant cache errored. Will continue operation with cleared cache" ; "err" => %e) ;
1116
1123
* * cache = LruCache :: new ( DESCENDANCY_CACHE_SIZE ) ;
@@ -1155,7 +1162,11 @@ pub trait SortitionHandle {
1155
1162
match Self :: descendancy_cache_get ( & mut cache, & cache_check_key) {
1156
1163
Some ( result) => {
1157
1164
if sn. sortition_id != top_sortition_id {
1158
- Self :: descendancy_cache_put ( & mut cache, ( top_sortition_id, cache_check_key. 1 ) , result) ;
1165
+ Self :: descendancy_cache_put (
1166
+ & mut cache,
1167
+ ( top_sortition_id, cache_check_key. 1 ) ,
1168
+ result,
1169
+ ) ;
1159
1170
}
1160
1171
return Ok ( result) ;
1161
1172
}
@@ -1164,11 +1175,19 @@ pub trait SortitionHandle {
1164
1175
}
1165
1176
1166
1177
if !sn. sortition {
1167
- Self :: descendancy_cache_put ( & mut cache, ( top_sortition_id, cache_check_key. 1 ) , false ) ;
1178
+ Self :: descendancy_cache_put (
1179
+ & mut cache,
1180
+ ( top_sortition_id, cache_check_key. 1 ) ,
1181
+ false ,
1182
+ ) ;
1168
1183
return Ok ( false ) ;
1169
1184
}
1170
1185
if & sn. winning_stacks_block_hash == potential_ancestor {
1171
- Self :: descendancy_cache_put ( & mut cache, ( top_sortition_id, cache_check_key. 1 ) , true ) ;
1186
+ Self :: descendancy_cache_put (
1187
+ & mut cache,
1188
+ ( top_sortition_id, cache_check_key. 1 ) ,
1189
+ true ,
1190
+ ) ;
1172
1191
return Ok ( true ) ;
1173
1192
}
1174
1193
@@ -1204,7 +1223,11 @@ pub trait SortitionHandle {
1204
1223
}
1205
1224
}
1206
1225
}
1207
- Self :: descendancy_cache_put ( & mut cache, ( top_sortition_id, potential_ancestor. clone ( ) ) , false ) ;
1226
+ Self :: descendancy_cache_put (
1227
+ & mut cache,
1228
+ ( top_sortition_id, potential_ancestor. clone ( ) ) ,
1229
+ false ,
1230
+ ) ;
1208
1231
return Ok ( false ) ;
1209
1232
}
1210
1233
}
0 commit comments