chore: improve function name

By describe why one would use it.
This commit is contained in:
fryorcraken.eth 2023-03-03 13:30:17 +11:00
parent a513087637
commit 031f4c0c21
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 4 additions and 4 deletions

View File

@ -194,7 +194,7 @@ describe("ENR", function () {
privateKey = hexToBytes(
"b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
);
record = await ENR.createV4(secp.getPublicKey(privateKey));
record = await ENR.createFromPublicKey(secp.getPublicKey(privateKey));
record.setLocationMultiaddr(multiaddr("/ip4/127.0.0.1/udp/30303"));
record.seq = seq;
await record.encodeTxt(privateKey);
@ -239,7 +239,7 @@ describe("ENR", function () {
privateKey = hexToBytes(
"b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
);
record = await ENR.createV4(secp.getPublicKey(privateKey));
record = await ENR.createFromPublicKey(secp.getPublicKey(privateKey));
});
it("should get / set UDP multiaddr", () => {

View File

@ -69,7 +69,7 @@ export class ENR extends Map<ENRKey, ENRValue> implements IEnr {
return enr;
}
static createV4(
static createFromPublicKey(
publicKey: Uint8Array,
kvs: Record<ENRKey, ENRValue> = {}
): Promise<ENR> {
@ -90,7 +90,7 @@ export class ENR extends Map<ENRKey, ENRValue> implements IEnr {
): Promise<ENR> {
switch (peerId.type) {
case "secp256k1":
return ENR.createV4(getPublicKeyFromPeerId(peerId), kvs);
return ENR.createFromPublicKey(getPublicKeyFromPeerId(peerId), kvs);
default:
throw new Error();
}