Помогите разобраться с кодом функции
const roll = ({ serverSeed, clientSeed, nonce }) => {
const nonceClientSeed = `${clientSeed}-${nonce}`;
const hex = createHmac('sha512', serverSeed)
.update(nonceClientSeed)
.digest('hex');
let index = 0;
let lucky = parseInt(hex.substring(index * 5, index * 5 + 5), 16);
while (lucky >= 1e6) {
index += 1;
lucky = parseInt(hex.substring(index * 5, index * 5 + 5), 16);
// we have reached the end of the hash and they all must have been ffffff
if (index * 5 + 5 > 129) {
lucky = 9999;
break;
}
}
return [lucky % 1e4] * 1e-2;
}
1.({ serverSeed, clientSeed, nonce }) что это такое и как передать значения, когда вызываешь функцию. 2. `${clientSeed}-${nonce}` - Клиент сид это число в шестнадцатеричной системе. Оно отнимает первое от второго? |
Цитата:
Цитата:
|
Цитата:
roll ({ serverSeed:value1, clientSeed:value2, nonce:value3 }) 2 Это эквивалентно String(clientSeed) + '-' + String(nonce) Ничего не отнимается, формируется строка |
| Часовой пояс GMT +3, время: 07:21. |