All files / src/utils pss.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1633x 33x                 33x 2x   2x    
import { PSS_TARGET_HEX_LENGTH_MAX } from '../types'
import { PeerAddress } from './typed-bytes'
 
/**
 * Utility function that for given strings/reference takes the most specific
 * target that Bee node will except.
 *
 * @param target is a non-prefixed hex string Bee address
 * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
 */
export function makeMaxTarget(target: PeerAddress | Uint8Array | string): string {
  target = new PeerAddress(target)
 
  return target.toHex().slice(0, PSS_TARGET_HEX_LENGTH_MAX)
}