public simController(int n, double res)
        {
            ledger_obj gen = new ledger_obj(1);

            byte[] a = new byte[100];
            gen.gen_ledger(dist.getUniformBetween(1, 100), a);

            double chosenStake, desire;

            sys_Time      = DateTime.Now;
            peersResource = new Dictionary <int, peer_obj>();

            //create the peer objects
            n_peers = n;
            for (int i = 0; i < n; i++)
            {
                peer_obj p = new peer_obj(i);
                p.localDist = dist;
                p.ledger.gen_ledger(gen.ledger[0].key, gen.ledger[0].value);
                desire      = p.gen_desiredStake(dist.getUniformBetween(0, 100));
                chosenStake = p.chooseStake();
                peersResource.Add(i, p);

                //Console.WriteLine("created peer : " + i + " : " + desire + " : " + chosenStake + " " + peersResource.Count);
            }
        }
Пример #2
0
        public peer_obj(int i)
        {
            ID             = i;
            leader_stat    = false;
            current_stake  = 0;
            desired_stake  = 0;
            ledger         = new ledger_obj(i);
            totLead        = 0;
            totalCheekLead = 0;
            totalStake     = 0;

            //for debuging include int seed
            //localDist = new distributions(1);
        }