예제 #1
0
 private void CheckForNext()
 {
     if (m_antiSpam.HasRequestAndTimepastEnough())
     {
         PublicRestRequest tosend = m_antiSpam.DequeueRquestToSend();
         StartCoroutine(tosend.SendRequest());
     }
 }
예제 #2
0
 public void AddFromUrl(string urlOfRequest, out PublicRestRequest request, List <PublicRestRequest> debugList = null)
 {
     request = new PublicRestRequestDefault(urlOfRequest);
     m_antiSpam.Add(request);
     if (debugList != null)
     {
         debugList.Add(request);
     }
 }
 public void CheckForChange(PublicRestRequest arg0)
 {
     if (arg0.HasBeenDownloaded() && !arg0.HasError() && arg0.HasText())
     {
         string json = arg0.GetText();
         if (json != m_previousJson)
         {
             m_apiHadBeenRefresh.Invoke();
             m_previousJson = json;
             //Debug.Log("Ping:" + m_previousJson);
         }
     }
 }
예제 #4
0
    private void ManageRequestCallback(PublicRestRequest requestReceived)
    {
        if (requestReceived is EthMineRequest_Workers)
        {
            WorkerRequestCastedCallback((EthMineRequest_Workers)requestReceived);
        }

        else
        {
            if (m_debugUnknowRequest)
            {
                Debug.Log("Received unable to cast:" + m_requestSender.ToString());
            }
        }
    }
예제 #5
0
    public PublicRestRequest DequeueRquestToSend()
    {
        if (m_toSend == null)
        {
            return(null);
        }
        PublicRestRequest r = m_toSend.Dequeue();

        if (r != null)
        {
            r.SendRequest();
            m_lastSendRequest = DateTime.Now;
            return(r);
        }
        return(null);
    }
예제 #6
0
 private void Callback(PublicRestRequest arg0)
 {
     if (arg0 == null)
     {
         return;
     }
     if (arg0 is EthMineRequest_WorkersHistory)
     {
         RecoverWorkHistory((EthMineRequest_WorkersHistory)arg0);
     }
     else if (arg0 is EthMineRequest_WorkersStatistics)
     {
         RecoverWorkStatistics((EthMineRequest_WorkersStatistics)arg0);
     }
     else if (arg0 is EthMineRequest_Workers)
     {
         RecovertListOfWorkers((EthMineRequest_Workers)arg0);
     }
     m_fetched.Invoke(arg0);
 }
    private void ManageRequestCallback(PublicRestRequest requestReceived)
    {
        if (requestReceived is EthScanRequest_GasOracle)
        {
            ManageRequestCastedCallback((EthScanRequest_GasOracle)requestReceived);
        }
        else if (requestReceived is EthScanRequest_SupplyOfEther)
        {
            ManageRequestCastedCallback((EthScanRequest_SupplyOfEther)requestReceived);
        }
        else if (requestReceived is EthScanRequest_EtherLastPrice)
        {
            ManageRequestCastedCallback((EthScanRequest_EtherLastPrice)requestReceived);
        }
        else if (requestReceived is EthScanRequest_EtheriumNodeCount)
        {
            ManageRequestCastedCallback((EthScanRequest_EtheriumNodeCount)requestReceived);
        }
        else if (requestReceived is EthScanRequest_GetBlockNumberByTimestamp)
        {
            ManageRequestCastedCallback((EthScanRequest_GetBlockNumberByTimestamp)requestReceived);
        }
        else if (requestReceived is EthScanRequest_GetBalance)
        {
            ManageRequestCastedCallback((EthScanRequest_GetBalance)requestReceived);
        }
        else if (requestReceived is EthScanRequest_GetBalanceOfWallets)
        {
            ManageRequestCastedCallback((EthScanRequest_GetBalanceOfWallets)requestReceived);
        }

        else
        {
            Debug.Log("Received unable to cast:" + m_requestSender.ToString());
        }
    }
예제 #8
0
 private void AddListenToAndPush(PublicRestRequest request)
 {
     request.AddListener(ManageRequestCallback);
     m_requestSender.AddRequest(request);
 }
예제 #9
0
    //public EthScanRequest_EtherLastPrice m_etherLastPrice;
    //public EthScanRequest_EtheriumNodeCount m_etherNodeCount;
    //public EthScanRequest_GasOracle m_etherGasOracle;
    //public EthScanRequest_GetBlockNumberByTimestamp m_etherBlocks;

    //public EthScanRequest_EstimationOfConfirmationTIme m_ehterGasEstimationTime;

    //public string m_targetTransactionFail;
    //public EthScanRequest_CheckContarctStatus m_transactionStateFail;
    //public string m_targetTransactionValide;
    //public EthScanRequest_CheckContarctStatus m_transactionStateValide;


    //public string m_addressWallet;
    //public EthScanRequest_GetBalance m_walletBalance;
    //public EthScanRequest_GetWalletTransaction m_walletTransaction;
    //public EthScanRequest_ERC20ByAddress m_walletErc20;
    //public EthScanRequest_ERC721ByAddress m_walletErc721;

    //public string[] m_address20Max = new string[20];
    //public EthScanRequest_GetBalanceOfWallets m_etherWallets;


    //public string ercContractAddress;
    //public string ercContractLinkedAddress;
    //public EthScanRequest_ERC20TokenSupplyByContract m_contact;
    //public EthScanRequest_ERC20TokenAccountBalanceForTokenContractAddress m_linkedContact;


    //public SupplyOfEtherChange supplyOfEtherListener;
    //public EtherLastPriceChange lastPriceListener;
    //public EtherNodeCount nodeCountListener;
    //public EhterCurrentBlockNumber blockNumberListener;
    //public EtherGasOracle gasOracleListener;
    //public WalletBalanceState walletStateListener;

    //public delegate void SupplyOfEtherChange(decimal supplyOfEther);
    //public delegate void EtherLastPriceChange(double lastPriceInBitcont, double lastPriceInDollar);
    //public delegate void EtherNodeCount(decimal nodeCount);
    //public delegate void EhterCurrentBlockNumber(decimal currentBlockNumber);
    //public delegate void EtherGasOracle(decimal safeGWei, decimal proposedInGwei, decimal fastInGwei);
    //public delegate void WalletBalanceState(string address, string weiState);



    //IEnumerator Start()
    //{
    //    m_etherSupply = new EthScanRequest_SupplyOfEther(m_etherScanApiToken);
    //    AddListenToAndPush(m_etherSupply);
    //    m_etherLastPrice = new EthScanRequest_EtherLastPrice(m_etherScanApiToken);
    //    AddListenToAndPush(m_etherLastPrice);
    //    m_etherNodeCount = new EthScanRequest_EtheriumNodeCount(m_etherScanApiToken);
    //    AddListenToAndPush(m_etherNodeCount);
    //    m_etherGasOracle = new EthScanRequest_GasOracle(m_etherScanApiToken);
    //    AddListenToAndPush(m_etherGasOracle);
    //    m_etherBlocks = new EthScanRequest_GetBlockNumberByTimestamp(m_etherScanApiToken);
    //    AddListenToAndPush(m_etherBlocks);

    //    CheckWalletState(m_addressWallet);
    //    CheckWalletStateMax20Accounts(m_address20Max);
    //    CheckWalletStateMoreThat20Accounts(m_address20Max);


    //    m_transactionStateFail = new EthScanRequest_CheckContarctStatus(m_etherScanApiToken, m_targetTransactionFail);
    //    AddListenToAndPush(m_transactionStateFail);
    //    m_transactionStateValide = new EthScanRequest_CheckContarctStatus(m_etherScanApiToken, m_targetTransactionValide);
    //    AddListenToAndPush(m_transactionStateValide);



    //    m_walletErc20 = new EthScanRequest_ERC20ByAddress(m_etherScanApiToken, m_addressWallet);
    //    AddListenToAndPush(m_walletErc20);
    //    m_walletErc721 = new EthScanRequest_ERC721ByAddress(m_etherScanApiToken, m_addressWallet);
    //    AddListenToAndPush(m_walletErc721);

    //    m_walletTransaction = new EthScanRequest_GetWalletTransaction(m_etherScanApiToken, m_addressWallet);
    //    AddListenToAndPush(m_walletTransaction);



    //    yield return new WaitForSeconds(10);


    //    m_ehterGasEstimationTime = new EthScanRequest_EstimationOfConfirmationTIme(m_etherScanApiToken, 80 + "000000000");
    //    CheckTransactionTimeForInGwei(m_etherGasOracle.m_gazProposeInGWei.ToString());


    //    m_contact = new EthScanRequest_ERC20TokenSupplyByContract(m_etherScanApiToken, ercContractAddress);
    //    AddListenToAndPush(m_etherWallets);
    //    m_linkedContact = new EthScanRequest_ERC20TokenAccountBalanceForTokenContractAddress(m_etherScanApiToken, ercContractAddress, ercContractLinkedAddress);
    //    AddListenToAndPush(m_etherWallets);


    //}
    //public void CheckTransactionTimeForInGwei(string gwei)
    //{
    //    AddListenToAndPush(new EthScanRequest_EstimationOfConfirmationTIme(m_etherScanApiToken, gwei + "000000000"));
    //}
    //public void CheckTransactionTimeForInWei(string wei)
    //{
    //    AddListenToAndPush(new EthScanRequest_EstimationOfConfirmationTIme(m_etherScanApiToken, wei));
    //}



    //public void CheckERC20(string address)
    //{
    //    AddListenToAndPush(new EthScanRequest_ERC20ByAddress(m_etherScanApiToken, m_addressWallet));
    //}
    //public void CheckERC721(string address)
    //{
    //    AddListenToAndPush(new EthScanRequest_ERC721ByAddress(m_etherScanApiToken, m_addressWallet));
    //}
    //public void CheckTransaction(string address)
    //{
    //    AddListenToAndPush(new EthScanRequest_GetWalletTransaction(m_etherScanApiToken, m_addressWallet));
    //}



    //public void CheckWalletState(string walletAddress)
    //{
    //    m_walletBalance = new EthScanRequest_GetBalance(m_etherScanApiToken, walletAddress);
    //    AddListenToAndPush(m_walletBalance);
    //}
    //public void CheckWalletStateMax20Accounts(params string[] walletAddress)
    //{
    //    m_etherWallets = new EthScanRequest_GetBalanceOfWallets(m_etherScanApiToken, walletAddress);
    //    AddListenToAndPush(m_etherWallets);

    //}
    //public void CheckWalletStateMoreThat20Accounts(params string[] walletAddress)
    //{
    //    int i = 0;
    //    List<string> addressStack = new List<string>();
    //    while (i < walletAddress.Length)
    //    {
    //        addressStack.Add(walletAddress[i]);
    //        if (addressStack.Count == 20)
    //        {
    //            AddListenToAndPush(new EthScanRequest_GetBalanceOfWallets(m_etherScanApiToken, addressStack.ToArray()));
    //            addressStack.Clear();
    //        }
    //        if (addressStack.Count > 20)
    //        {
    //            Debug.LogError("Big problem here. Contact developer, the spliting of address by group of 20 did not work  properly.");
    //        }

    //        i++;
    //    }
    //    if (addressStack.Count > 0)
    //    {
    //        AddListenToAndPush(new EthScanRequest_GetBalanceOfWallets(m_etherScanApiToken, addressStack.ToArray()));
    //        addressStack.Clear();
    //    }
    //}

    private void AddListenerTo(PublicRestRequest request)
    {
        request.AddListener(ManageRequestCallback);
    }
예제 #10
0
 public void SendRequest(string address)
 {
     m_request = new PublicRestRequestDefault(string.Format(m_serverUrl, m_defaultAddress));
     m_antiSpam.AddRequest(m_request);
 }
예제 #11
0
 public void Add(PublicRestRequest request)
 {
     m_toSend.Enqueue(request);
 }
예제 #12
0
 public void AddRequest(PublicRestRequest request)
 {
     m_antiSpam.Add(request);
 }
예제 #13
0
 public void Push(PublicRestRequest toPush)
 {
     toPush.AddListener(Callback);
     m_antiSpamRequest.AddRequest(toPush);
 }
예제 #14
0
 public void Debug(PublicRestRequest request)
 {
     m_url.Invoke(request.GetUsedUrl());
     m_json.Invoke(request.GetText());
     m_error.Invoke(request.GetError());
 }