#!/usr/bin/fift -s "TonUtil.fif" include "Asm.fif" include { ."usage: " $0 type ." []" cr ."Creates a new proof-of-work testgiver with unique 32-bit identifier designed to deliver every seconds, with SHA256 hash complexity between 2** and 2**, with private key saved to or loaded from .pk" cr ."('pow-giver.pk' by default)" cr 1 halt } : usage $# 7 - -2 and ' usage if 8 :$1..n $1 parse-workchain-id =: wc // set workchain id from command line argument $2 parse-int dup =: subwallet-id 0= abort"giver-id must be non-zero" $3 $>GR =: amount $4 parse-int dup =: interval dup 24 ufits and 0= abort"invalid interval" $5 parse-int dup =: min-cpl 1- 8 ufits not abort"invalid minimal log-complexity (must be 1..256)" $6 parse-int dup =: init-cpl 1- 8 ufits not abort"invalid initial log-complexity (must be 1..256)" $7 parse-int dup =: max-cpl 1- 8 ufits not abort"invalid maximal log-complexity (must be 1..256)" $8 "pow-giver" replace-if-null =: file-base min-cpl init-cpl > abort"initial complexity cannot be below minimal complexity" max-cpl init-cpl < abort"initial complexity cannot exceed maximal complexity" subwallet-id (.) 1 ' $+ does : +subwallet ."Creating new proof-of-work testgiver in workchain " wc . ."with unique giver id " subwallet-id . cr ."Designed to give " amount .GR ."approximately every " interval . ."seconds" cr ."Complexity (in SHA256 hashes): min=" min-cpl 1<< . ."init=" init-cpl 1<< . ."max=" max-cpl 1<< . cr "auto/pow-testgiver-code.fif" include // code { 256 swap - 8 u, } : cpl, ref, b> // data null // no libraries // create StateInit dup ."StateInit: " dup ."signing message: " dup ."External message for initialization is " B dup Bx. cr file-base +subwallet +"-query.boc" tuck B>file ."(Saved proof-of-work testgiver creating query to file " type .")" cr