forked from Consensys/teku
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to epoch metrics + cache only most recent blocks
- Loading branch information
Showing
9 changed files
with
128 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
dependencies { | ||
implementation 'com.google.guava:guava' | ||
implementation 'org.apache.commons:commons-collections4' | ||
|
||
|
||
testFixturesImplementation 'it.unimi.dsi:fastutil' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../main/java/tech/pegasys/teku/infrastructure/collections/SynchronizedSortedLimitedMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2022 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package tech.pegasys.teku.infrastructure.collections; | ||
|
||
import java.util.Collections; | ||
import java.util.Comparator; | ||
|
||
/** Helper that creates a thread-safe sorted map with a maximum capacity. */ | ||
final class SynchronizedSortedLimitedMap<K, V> extends AbstractLimitedMap<K, V> { | ||
final Comparator<? super K> keyComparator; | ||
final Comparator<? super V> valueComparator; | ||
|
||
public SynchronizedSortedLimitedMap( | ||
final int maxSize, | ||
final Comparator<? super K> keyComparator, | ||
final Comparator<? super V> valueComparator) { | ||
super( | ||
Collections.synchronizedMap( | ||
createSortedLimitedMap(maxSize, keyComparator, valueComparator)), | ||
maxSize); | ||
this.keyComparator = keyComparator; | ||
this.valueComparator = valueComparator; | ||
} | ||
|
||
@Override | ||
public LimitedMap<K, V> copy() { | ||
SynchronizedSortedLimitedMap<K, V> map = | ||
new SynchronizedSortedLimitedMap<>(getMaxSize(), keyComparator, valueComparator); | ||
synchronized (delegate) { | ||
map.putAll(delegate); | ||
} | ||
return map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters