You are viewing a single comment's thread from:

RE: Hashcash Algorithm in F#

in #fsharp7 years ago

You can get rid of mutation and further simplify your implementation:

let sender () =                                                                                                                                         
    let randomString = randomChars 8                                                                                                                    
    let counter = Seq.initInfinite ((+) 1)                                                                                                              
                  |> Seq.take 2000000  //limit so it does not run forever                                                                               
                  |> Seq.pick (fun index -> if compute index randomString then Some index else None)                                                    
    printfn "FINAL COUNT %i " counter                                                                                                                   
    printfn "HASH %s" (header counter randomString)      

and compute:

let compute index randomString =                                                                                                                        
    getHash (header index randomString) |> checkHash 

Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.026
BTC 56989.27
ETH 2425.90
USDT 1.00
SBD 2.39