Esempio n. 1
0
        public void CalculateHashFast()
        {
            var buf = new byte[32];

            // fast-mode
            LibRandomX.CreateSeed(realm, seedHex, null, LibRandomX.randomx_flags.RANDOMX_FLAG_FULL_MEM);

            LibRandomX.CalculateHash("xmr", seedHex, data, buf);
            var result = buf.ToHexString();

            Assert.Equal(hashExpected, result);

            Array.Clear(buf, 0, buf.Length);

            // second invocation should give the same result
            LibRandomX.CalculateHash("xmr", seedHex, data, buf);
            result = buf.ToHexString();
            Assert.Equal(hashExpected, result);

            LibRandomX.DeleteSeed(realm, seedHex);
        }
Esempio n. 2
0
        public void CalculateHashSlow()
        {
            var buf = new byte[32];

            // light-mode
            LibRandomX.CreateSeed(realm, seedHex);

            LibRandomX.CalculateHash("xmr", seedHex, data, buf);
            var result = buf.ToHexString();

            Assert.Equal(hashExpected, result);

            Array.Clear(buf, 0, buf.Length);

            // second invocation should give the same result
            LibRandomX.CalculateHash("xmr", seedHex, data, buf);
            result = buf.ToHexString();
            Assert.Equal(hashExpected, result);

            LibRandomX.DeleteSeed(realm, seedHex);
        }
Esempio n. 3
0
        public CryptonoteJob(GetBlockTemplateResponse blockTemplate, byte[] instanceId, string jobId,
                             CryptonoteCoinTemplate coin, PoolConfig poolConfig, ClusterConfig clusterConfig, string prevHash, string randomXRealm)
        {
            Contract.RequiresNonNull(blockTemplate, nameof(blockTemplate));
            Contract.RequiresNonNull(poolConfig, nameof(poolConfig));
            Contract.RequiresNonNull(clusterConfig, nameof(clusterConfig));
            Contract.RequiresNonNull(instanceId, nameof(instanceId));
            Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(jobId), $"{nameof(jobId)} must not be empty");

            BlockTemplate = blockTemplate;
            PrepareBlobTemplate(instanceId);
            PrevHash = prevHash;

            switch (coin.Hash)
            {
            case CryptonightHashType.RandomX:
                hashFunc = ((seedHex, data, result, height) =>
                {
                    LibRandomX.CalculateHash(randomXRealm, seedHex, data, result);
                });
                break;
            }
        }