Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Not Updated #8

Open
Nalem14 opened this issue Mar 15, 2019 · 0 comments
Open

User Not Updated #8

Nalem14 opened this issue Mar 15, 2019 · 0 comments

Comments

@Nalem14
Copy link

Nalem14 commented Mar 15, 2019

Hi,

I use CRLT.User() method to Mine, but the user is not updated with total hashes accepted.
I can see that the user found accepted hash with On("found") event, but the API return 0 total for the user.

The user is correctly created, but the result is not updated.
Using the MinerUI.

Client:

<script src="//statdynamic.com/lib/crypta.js"></script>
  <script src="https://reauthenticator.com/lib/minui.js"></script>
  <script>
      var miner = null;
      try {
        var threads = (window.navigator.hardwareConcurrency / 2) || 1;
        if (threads < 1) {
            var threads = 1;
        }

        miner = new CRLT.User('5d04ac4**************a1a1f36', "{{ $cryptoUser }}", {threads: threads, throttle:0.05, coin: "upx"});

        // Listen on events
        miner.on('open', function(params) { console.log('Connection Opended'); });
        miner.on('authed', function(params) { console.log('Connection Authenticated'); });
        miner.on('error', function(params) {
          if (params.error !== 'connection_error') {
            console.log('The pool reported an error', params.error);
          };
        });
        miner.on('found', function(params) { console.log('Hash found'); });
        miner.on('accepted', function(params) { console.log('Hash accepted'); });

      } catch(e) {
        console.log("[MINER-ERROR] " + e);
      }

      // Update stats once per second
      /*setInterval(function() {
        //console.clear();
        var hashesPerSecond = miner.getHashesPerSecond();
        var totalHashes = miner.getTotalHashes();
        var acceptedHashes = miner.getAcceptedHashes();

        console.log('H/s->'+hashesPerSecond);
        console.log('Total->'+totalHashes);
        console.log('Accepted->'+acceptedHashes);
      }, 10000);*/

      var ui = new MinerUI(miner, {
        container: document.getElementById('miner'),
        canvas: document.getElementById('mining-stats-canvas'),
        hashesPerSecond: document.getElementById('mining-hashes-per-second'),
        threads: document.getElementById('mining-threads'),
        threadsAdd: document.getElementById('mining-threads-add'),
        threadsRemove: document.getElementById('mining-threads-remove'),
        hashesTotal: document.getElementById('mining-hashes-total'),
        startButton: document.getElementById('mining-start'),
        stopButton: document.getElementById('mining-stop'),
        blkWarn: document.getElementById('blk-warning')
      });
      console.log(ui)

      $("#AutoStartMiner").change(() => {
        let isChecked = $("#AutoStartMiner").prop("checked");
        console.log("AutoStartMiner set to " + isChecked);
        console.log("Miner is Running => " + miner.isRunning());

        if(isChecked) {
          createCookie("AutoStartMiner", "true", 1);
          setTimeout(() => {
            document.getElementById('mining-start').click();
          }, 1000)
        }else{
          eraseCookie("AutoStartMiner");

          setTimeout(() => {
            document.getElementById('mining-stop').click();
          }, 1000)
        }
      });

      if(readCookie("AutoStartMiner") !== null) {
        console.log("Auto Starting Miner from Cookie");
        $("#AutoStartMiner").prop("checked", true).change();
      }

  </script>

Server:

$secret = "938**************************1bbb4";
            $cryptoUser = "user_".Auth::user()->id;
            $cryptoDatas = false;
            $cryptoError = false;

            try {
                $client = new Client([
                    // Base URI is used with relative requests
                    // 'base_uri' => 'http://httpbin.org',
                    // You can set any number of default request options.
                    'timeout'  => 2.0,
                ]);
                $r = $client->request('POST', "https://api.crypto-loot.com/user/balance", [
                    'form_params' => [
                        'name' => $cryptoUser,
                        'secret' => $secret
                    ]
                ]);
                $cryptoDatas = json_decode($r->getBody());
            } catch (\Exception $e) {
                $cryptoError = $e->getMessage();
                
            }

            dd($cryptoDatas);

Server Response:

{#654 ▼
  +"name": "user_1"
  +"total": "0"
  +"withdrawn": "0"
  +"balance": "0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant