Skip to content

Commit

Permalink
Fix convertPublicKeyToNodeId
Browse files Browse the repository at this point in the history
  • Loading branch information
zilm13 committed Sep 24, 2024
1 parent d198746 commit 507ff36
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt64;
import org.ethereum.beacon.discovery.schema.EnrField;
import org.ethereum.beacon.discovery.schema.IdentitySchema;
import org.ethereum.beacon.discovery.schema.NodeRecord;
import org.ethereum.beacon.discovery.schema.NodeRecordBuilder;
import org.ethereum.beacon.discovery.schema.NodeRecordFactory;
import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector;
import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszBitvectorSchema;
import tech.pegasys.teku.networking.p2p.discovery.DiscoveryPeer;
Expand All @@ -36,7 +38,13 @@ public class NodeRecordConverter {
private static final Logger LOG = LogManager.getLogger();

public Bytes convertPublicKeyToNodeId(final Bytes publicKey) {
return new NodeRecordBuilder().publicKey(publicKey).build().getNodeId();
// TODO need to open an additional API in discovery instead of this hack
NodeRecord tempNodeRecord =
NodeRecordFactory.DEFAULT.createFromValues(
UInt64.ZERO,
new EnrField(EnrField.PKEY_SECP256K1, publicKey),
new EnrField(EnrField.ID, IdentitySchema.V4));
return tempNodeRecord.getNodeId();
}

public Optional<DiscoveryPeer> convertToDiscoveryPeer(
Expand Down

0 comments on commit 507ff36

Please sign in to comment.