Skip to content

Commit

Permalink
reverting artifactsignerprovider changes
Browse files Browse the repository at this point in the history
  • Loading branch information
usmansaleem committed Nov 21, 2024
1 parent 159ed01 commit 3588952
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package tech.pegasys.web3signer.signing;

import java.io.Closeable;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -43,12 +44,12 @@ public interface ArtifactSignerProvider extends Closeable {
Set<String> availableIdentifiers();

/**
* Get the proxy public keys for the given consensus public key. Used for commit boost API.
* Get the proxy identifiers for the given identifier. Used for commit boost API.
*
* @param consensusPubKey the identifier of the consensus signer
* @param identifier the identifier of the signer
* @return Map of Key Type (BLS, SECP256K1) and corresponding proxy identifiers
*/
Map<KeyType, Set<String>> getProxyIdentifiers(final String consensusPubKey);
Map<KeyType, List<String>> getProxyIdentifiers(final String identifier);

/**
* Add a new signer to the signer provider.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand All @@ -45,7 +46,7 @@ public class DefaultArtifactSignerProvider implements ArtifactSignerProvider {
private static final Logger LOG = LogManager.getLogger();
private final Supplier<Collection<ArtifactSigner>> artifactSignerCollectionSupplier;
private final Map<String, ArtifactSigner> signers = new HashMap<>();
private final Map<String, Set<ArtifactSigner>> proxySigners = new HashMap<>();
private final Map<String, List<ArtifactSigner>> proxySigners = new HashMap<>();
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
private final Optional<KeystoresParameters> commitBoostKeystoresParameters;

Expand Down Expand Up @@ -116,14 +117,14 @@ public Set<String> availableIdentifiers() {
}

@Override
public Map<KeyType, Set<String>> getProxyIdentifiers(final String consensusPubKey) {
final Set<ArtifactSigner> artifactSigners =
proxySigners.computeIfAbsent(consensusPubKey, k -> Set.of());
public Map<KeyType, List<String>> getProxyIdentifiers(final String identifier) {
final List<ArtifactSigner> artifactSigners =
proxySigners.computeIfAbsent(identifier, k -> List.of());
return artifactSigners.stream()
.collect(
Collectors.groupingBy(
ArtifactSigner::getKeyType,
Collectors.mapping(ArtifactSigner::getIdentifier, Collectors.toSet())));
Collectors.mapping(ArtifactSigner::getIdentifier, Collectors.toList())));
}

@Override
Expand All @@ -141,7 +142,6 @@ public Future<Void> removeSigner(final String identifier) {
return executorService.submit(
() -> {
signers.remove(identifier);
proxySigners.remove(identifier);
LOG.info("Removed signer with identifier '{}'", identifier);
return null;
});
Expand All @@ -168,7 +168,7 @@ private void loadSecpProxySigners(
SecpV3KeystoresBulkLoader.loadV3KeystoresUsingPasswordFileOrDir(
proxySecpDir, keystoreParameter.getKeystoresPasswordFile());
final Collection<ArtifactSigner> secpSigners = secpSignersResults.getValues();
proxySigners.computeIfAbsent(identifier, k -> new HashSet<>()).addAll(secpSigners);
proxySigners.computeIfAbsent(identifier, k -> new ArrayList<>()).addAll(secpSigners);
}
}

Expand All @@ -184,7 +184,7 @@ private void loadBlsProxySigners(
BlsKeystoreBulkLoader.loadKeystoresUsingPasswordFile(
proxyBlsDir, keystoreParameter.getKeystoresPasswordFile());
final Collection<ArtifactSigner> blsSigners = blsSignersResult.getValues();
proxySigners.computeIfAbsent(identifier, k -> new HashSet<>()).addAll(blsSigners);
proxySigners.computeIfAbsent(identifier, k -> new ArrayList<>()).addAll(blsSigners);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import tech.pegasys.web3signer.signing.KeyType;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -68,7 +69,7 @@ public Set<String> availableIdentifiers() {
}

@Override
public Map<KeyType, Set<String>> getProxyIdentifiers(final String identifier) {
public Map<KeyType, List<String>> getProxyIdentifiers(final String identifier) {
throw new NotImplementedException();
}

Expand Down

0 comments on commit 3588952

Please sign in to comment.