proof of stake algorithm code