Ejemplo n.º 1
0
 public DelegateInfo GetDelegate(NodeClient client, string hash, string addr, bool forceUpdate = false, bool enqueue = false)
 {
     try
     {
         if (_tzKtUrl == null)
         {
             return(client.GetDelegateInfo(addr, hash));
         }
         var str       = client.Download(_tzKtUrl + "v1/accounts/" + addr);
         var @delegate = JsonConvert.DeserializeObject <TzKt.Account>(str);
         if (@delegate.type != "delegate")
         {
             return(null);
         }
         var str_d = client.Download(_tzKtUrl + "v1/accounts/" + addr + "/delegators");
         return(new DelegateInfo
         {
             balance = @delegate.balance - @delegate.frozenDeposits - @delegate.frozenRewards - @delegate.frozenFees,
             deactivated = [email protected],
             staking_balance = @delegate.stakingBalance,
             bond = @delegate.balance,                    //@delegate.balance ,
             Hash = hash,
             delegated_contracts = JsonConvert.DeserializeObject <TzKt.Delegator[]>(str_d).Select(d => d.address).ToList(),
             NumDelegators = @delegate.numDelegators
         });
     }
     catch
     {
         var di = client.GetDelegateInfo(addr, hash);
         di.Hash          = hash;
         di.NumDelegators = di.delegated_contracts.Count;
         return(di ?? new DelegateInfo());
     }
 }