powPolicy: add example

This commit is contained in:
Alex Gleason 2023-04-18 18:30:42 -04:00
parent 33ef127ca7
commit 6f77ec418b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

View File

@ -8,7 +8,14 @@ interface POW {
difficulty?: number; difficulty?: number;
} }
/** Reject events which don't meet Proof-of-Work ([NIP-13](https://github.com/nostr-protocol/nips/blob/master/13.md)) criteria. */ /**
* Reject events which don't meet Proof-of-Work ([NIP-13](https://github.com/nostr-protocol/nips/blob/master/13.md)) criteria.
*
* @example
* ```ts
* powPolicy(msg, { difficulty: 20 });
* ```
*/
const powPolicy: Policy<POW> = ({ event }, opts = {}) => { const powPolicy: Policy<POW> = ({ event }, opts = {}) => {
const { difficulty = 1 } = opts; const { difficulty = 1 } = opts;