Skip to content

Commit

Permalink
Fix writing ids to file in mkid
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaBlume99 committed Jul 4, 2023
1 parent 6fd8c8c commit 8f5f0c8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions rt/src/p2p/mkid.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
'use strict';
import * as fs from 'node:fs'
import * as fsPromises from 'node:fs/promises';
// const fsPromises = require('fs').promises
import PeerId from "peer-id";
//const args = require('yargs').argv;
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import pkg from 'yargs'
const {argv} = pkg;

Expand All @@ -27,8 +26,13 @@ async function ensureFileDoesntExist (f) {
}

(async () => {
let id = await PeerId.create();
const obj = id.toJSON();
let peerid = await createEd25519PeerId();

const obj = {
id : peerid.toString(),
privKey : uint8ArrayToString(peerid.privateKey, 'base64pad'),
pubKey : uint8ArrayToString(peerid.publicKey, 'base64pad')
};
if (argv.verbose) {
console.log("Created key with id:", obj.id);
}
Expand Down

0 comments on commit 8f5f0c8

Please sign in to comment.