mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-22 21:45:56 +03:00
updates heavy-stones to new miner schema
This commit is contained in:
parent
dd94b8eeab
commit
09616a611d
@ -16,6 +16,8 @@ import { v4 as uuid } from "uuid";
|
|||||||
const envConfig = configs["development"];
|
const envConfig = configs["development"];
|
||||||
const db = knex(envConfig);
|
const db = knex(envConfig);
|
||||||
|
|
||||||
|
// 64 MB minimum
|
||||||
|
const MINIMUM_BYTES_CONSIDERATION = 67108864;
|
||||||
// 100 MB minimum
|
// 100 MB minimum
|
||||||
const MINIMUM_BYTES_FOR_STORAGE = 104857600;
|
const MINIMUM_BYTES_FOR_STORAGE = 104857600;
|
||||||
const STORAGE_BOT_NAME = "STORAGE WORKER";
|
const STORAGE_BOT_NAME = "STORAGE WORKER";
|
||||||
@ -48,8 +50,8 @@ const run = async () => {
|
|||||||
|
|
||||||
jsonData.data.forEach((group) => {
|
jsonData.data.forEach((group) => {
|
||||||
group.minerAddresses.forEach((entity) => {
|
group.minerAddresses.forEach((entity) => {
|
||||||
minerMap[entity.miner] = entity;
|
minerMap[entity.id] = entity;
|
||||||
minerMap[entity.miner.replace("t", "f")] = entity;
|
minerMap[entity.id.replace("t", "f")] = entity;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -57,8 +59,6 @@ const run = async () => {
|
|||||||
const response = await Data.getEveryUser(false);
|
const response = await Data.getEveryUser(false);
|
||||||
|
|
||||||
let storageUsers = [];
|
let storageUsers = [];
|
||||||
const writable = [];
|
|
||||||
const slateAddresses = [];
|
|
||||||
let bytes = 0;
|
let bytes = 0;
|
||||||
let dealUsers = 0;
|
let dealUsers = 0;
|
||||||
let totalUsers = 0;
|
let totalUsers = 0;
|
||||||
@ -127,14 +127,14 @@ const run = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printData.bytes = userBytes;
|
|
||||||
|
|
||||||
// NOTE(jim): Skip people.
|
// NOTE(jim): Skip people.
|
||||||
if (userBytes < MINIMUM_BYTES_FOR_STORAGE) {
|
if (userBytes < MINIMUM_BYTES_CONSIDERATION) {
|
||||||
Logs.note(`SKIP: ${user.username}`);
|
Logs.note(`SKIP: ${user.username}, they only have ${Strings.bytesToSize(userBytes)}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printData.bytes = userBytes;
|
||||||
|
|
||||||
const PowergateSingleton = await Utilities.getPowergateAPIFromUserToken({
|
const PowergateSingleton = await Utilities.getPowergateAPIFromUserToken({
|
||||||
user,
|
user,
|
||||||
});
|
});
|
||||||
@ -157,16 +157,6 @@ const run = async () => {
|
|||||||
Logs.error(e.message);
|
Logs.error(e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address) {
|
|
||||||
slateAddresses.push(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(jim): Exit early for analytics purposes.
|
|
||||||
if (STORE_MEANINGFUL_ADDRESS_ONLY_AND_PERFORM_NO_ACTIONS) {
|
|
||||||
Logs.taskTimeless(`Adding address for: ${user.username}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let storageDeals = [];
|
let storageDeals = [];
|
||||||
try {
|
try {
|
||||||
const listStorageResult = await power.listStorageDealRecords({
|
const listStorageResult = await power.listStorageDealRecords({
|
||||||
@ -197,10 +187,9 @@ const run = async () => {
|
|||||||
activationEpoch: o.dealInfo.activationEpoch,
|
activationEpoch: o.dealInfo.activationEpoch,
|
||||||
time: o.time,
|
time: o.time,
|
||||||
pending: o.pending,
|
pending: o.pending,
|
||||||
minerId: o.dealInfo.miner,
|
|
||||||
miner: { ...minerMap[o.dealInfo.miner], id: o.dealInfo.miner },
|
|
||||||
createdAt: Strings.toDateSinceEpoch(o.time),
|
createdAt: Strings.toDateSinceEpoch(o.time),
|
||||||
userEncryptsDeals: !!user.data.allow_encrypted_data_storage,
|
userEncryptsDeals: !!user.data.allow_encrypted_data_storage,
|
||||||
|
miner: minerMap[o.dealInfo.miner] ? minerMap[o.dealInfo.miner] : { id: o.dealInfo.miner },
|
||||||
user: {
|
user: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
username: user.username,
|
username: user.username,
|
||||||
@ -247,6 +236,12 @@ const run = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(jim): Exit early for analytics purposes.
|
||||||
|
if (STORE_MEANINGFUL_ADDRESS_ONLY_AND_PERFORM_NO_ACTIONS) {
|
||||||
|
Logs.taskTimeless(`Adding address for: ${user.username}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE(jim): Skip users that are out of funds.
|
// NOTE(jim): Skip users that are out of funds.
|
||||||
if (balance === 0) {
|
if (balance === 0) {
|
||||||
Logs.error(`OUT OF FUNDS: ${user.username}`);
|
Logs.error(`OUT OF FUNDS: ${user.username}`);
|
||||||
@ -409,8 +404,6 @@ const run = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writable.push(printData);
|
|
||||||
|
|
||||||
for (let k = 0; k < printData.buckets.length; k++) {
|
for (let k = 0; k < printData.buckets.length; k++) {
|
||||||
let targetBucket = printData.buckets[k];
|
let targetBucket = printData.buckets[k];
|
||||||
|
|
||||||
@ -432,22 +425,6 @@ const run = async () => {
|
|||||||
Logs.task(`total storage per run (with replication x5): ${Strings.bytesToSize(bytes * 5)}`);
|
Logs.task(`total storage per run (with replication x5): ${Strings.bytesToSize(bytes * 5)}`);
|
||||||
Logs.task(`creating slate-storage-addresses.json`);
|
Logs.task(`creating slate-storage-addresses.json`);
|
||||||
|
|
||||||
fs.writeFile(
|
|
||||||
"slate-storage-addresses.json",
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
rootAddress:
|
|
||||||
"t3xhj6odc2cjj3z6kmxqugjjai2unacme65gnwigse4xx6jcpmfmi6jg6miqintibacluxi4ydlmolfpruznba",
|
|
||||||
addresses: slateAddresses,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
),
|
|
||||||
function (e) {
|
|
||||||
if (e) return Logs.error(e.message);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`${STORAGE_BOT_NAME} finished. \n\n`);
|
console.log(`${STORAGE_BOT_NAME} finished. \n\n`);
|
||||||
console.log(`FINISHED: worker-heavy-stones.js`);
|
console.log(`FINISHED: worker-heavy-stones.js`);
|
||||||
console.log(` CTRL +C to return to terminal.`);
|
console.log(` CTRL +C to return to terminal.`);
|
||||||
|
Loading…
Reference in New Issue
Block a user