ChainSafe / discv5

A Typescript implementation of the Discv5 protocol
Apache License 2.0
28 stars 15 forks source link

feat!: remove broadcastTalkReq #282

Closed wemeetagain closed 7 months ago

wemeetagain commented 7 months ago

BREAKING CHANGE: broadcastTalkReq has been removed since it was very opinionated and can be trivially reproduced using kadValues and sendTalkReq.

function broadcastTalkReq(
  discv5: IDiscv5, payload: Buffer, protocol: string | Uint8Array
): Promise<Buffer> {
  const requests = []
  for (const enr of discv5.kadValues()) {
    requests.push(discv5.sendTalkReq(enr, payload, protocol)
  }
  // Depending on the use case
  // you might want to replace with Promise.allSettled
  // to return all responses / errors
  return Promise.race(requests)
}