Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
  • Loading branch information
bajtos committed Oct 3, 2024
1 parent 8214ca9 commit 9a51a58
Show file tree
Hide file tree
Showing 3 changed files with 3,654 additions and 1 deletion.
28 changes: 28 additions & 0 deletions identify-miner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { rpc } from './lib/miner-info.js'
import { decodeBase64 } from './vendor/deno-deps.js'
import { multiaddr } from './vendor/multiaddr.js'

const minerId = 'f03156722'

const info = await rpc('Filecoin.StateMinerInfo', minerId, null)
console.log(info)

const binary = info.Multiaddrs[0]
console.log(binary)
const bytes = decodeBase64(binary)
console.log(bytes)
const addr = multiaddr(bytes)
console.log(addr)
console.log(addr.toString())

const res = await Zinnia.requestProtocol(
addr.toString() + '/p2p/' + info.PeerId,
'/ipfs/id/1.0.0',
new Uint8Array(0)
)

const chunks = []
for await (const chunk of res) {
chunks.push(chunk);
}
console.log('RESPONSE', chunks)
2 changes: 1 addition & 1 deletion lib/miner-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function getMinerPeerId (minerId, { maxAttempts = 5 } = {}) {
* @param {string} method
* @param {unknown[]} params
*/
async function rpc (method, ...params) {
export async function rpc (method, ...params) {
const req = new Request(RPC_URL, {
method: 'POST',
headers: {
Expand Down
Loading

0 comments on commit 9a51a58

Please sign in to comment.