async function testAsync(data, str) {
const res1 = await new Promise((res) => {
async function testFun(i) {
let arr = [];
let index = await new Promise((second) => {
second(i);
if (step * i >= data.length) {
for (let j = step * (i - 1); j < data.length; j++) {
let obj = {};
obj.sign = keyring.signstring(data[j], privateKey);
obj.hash = data[j];
obj.id = j;
arr.push(obj);
arr.id = j;
}
} else {
for (let j = step * (i - 1); j < step * i; j++) {
let obj = {};
obj.sign = keyring.signstring(data[j], privateKey);
obj.hash = data[j];
obj.id = j;
arr.push(obj);
arr.id = j;
}
}
});
let list = {
count: count,
id: id,
hashs: arr
};
i++;
let result = await dispatch({
type: 'miningInfo/minegetminenewsign',
payload: list
});
// console.log(result);
console.log(arr);
console.log(index, data.length);
if (result.code === 0) {
if (index * step < data.length) {
console.log('++++');
testFun(i);
} else {
res(str);
}
}
}
testFun(1);
});
return res1;
}
async
关注
打赏