Skip to content

Commit 73bd266

Browse files
committed
Initial logging updates to Reputation Miner
1 parent aaf8c9e commit 73bd266

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

packages/reputation-miner/ReputationMiner.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,9 @@ class ReputationMiner {
734734

735735
async getEntryIndex(startIndex = 1) {
736736
// Get how much we've staked, and thefore how many entries we have
737-
const [stakeAmount] = await this.colonyNetwork.getMiningStake(this.minerAddress);
737+
const minerStake = await this.getMiningStake();
738738

739-
for (let i = ethers.BigNumber.from(startIndex); i.lte(stakeAmount.div(minStake)); i = i.add(1)) {
739+
for (let i = ethers.BigNumber.from(startIndex); i.lte(minerStake.amount.div(minStake)); i = i.add(1)) {
740740
const submissionPossible = await this.submissionPossible(i);
741741
if (submissionPossible) {
742742
return i;
@@ -769,13 +769,13 @@ class ReputationMiner {
769769
}
770770

771771
// Check the proposed entry is eligible (emulates entryQualifies modifier behaviour)
772-
const [stakeAmount, stakeTimestamp] = await this.colonyNetwork.getMiningStake(this.minerAddress);
772+
const minerStake = await this.getMiningStake();
773773

774-
if (ethers.BigNumber.from(entryIndex).gt(stakeAmount.div(minStake))) {
774+
if (ethers.BigNumber.from(entryIndex).gt(minerStake.amount.div(minStake))) {
775775
return false;
776776
}
777777

778-
if(reputationMiningWindowOpenTimestamp.lt(stakeTimestamp)) {
778+
if(reputationMiningWindowOpenTimestamp.lt(minerStake.timestamp)) {
779779
return false;
780780
}
781781

@@ -799,6 +799,22 @@ class ReputationMiner {
799799
return true;
800800
}
801801

802+
/**
803+
* Get the stake for the miner
804+
* @return {Promise} Resolves to the mining stake, {amount, timestamp}
805+
*/
806+
getMiningStake() {
807+
return this.colonyNetwork.getMiningStake(this.minerAddress);
808+
}
809+
810+
/**
811+
* Get the minimum stake for reputation mining
812+
* @return {integer} The minimum stake
813+
*/
814+
getMinStake() {
815+
return minStake;
816+
}
817+
802818
/**
803819
* Get the mining cycle duration.
804820
* @return {integer} Mining cycle duration
@@ -1270,7 +1286,7 @@ class ReputationMiner {
12701286
}
12711287

12721288
for (let i = syncFromIndex; i < events.length; i += 1) {
1273-
console.log(`Syncing mining cycle ${i + 1} of ${events.length}...`)
1289+
console.log(`${new Date().toLocaleTimeString()}: Syncing mining cycle ${i + 1} of ${events.length}...`)
12741290
const event = events[i];
12751291
if (i === 0) {
12761292
// If we are syncing from the very start of the reputation history, the block

packages/reputation-miner/ReputationMinerClient.js

+4
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ class ReputationMinerClient {
224224
this.resolveBlockChecksFinished = undefined;
225225
await this._miner.initialise(colonyNetworkAddress);
226226

227+
const minerStake = await this._miner.getMiningStake();
228+
const numEntries = minerStake.amount.div(this._miner.getMinStake());
229+
this._adapter.log(`Miner has staked ${minerStake.amount} CLNY, allowing up to ${numEntries} entries per cycle`);
230+
227231
// Get latest state from database if available, otherwise sync to current state on-chain
228232
const latestReputationHash = await this._miner.colonyNetwork.getReputationRootHash();
229233
await this._miner.createDB();

truffle.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,23 @@ module.exports = {
4141
gasPrice: 0,
4242
network_id: "1",
4343
},
44+
mainnet: {
45+
provider: () => {
46+
return new HDWalletProvider("private-key", "https://mainnet.infura.io/v3/infura-key");
47+
},
48+
network_id: "1",
49+
},
4450
goerli: {
4551
provider: () => {
46-
return new HDWalletProvider("replace-with-private-key-when-using", "https://goerli.infura.io/v3/e21146aa267845a2b7b4da025178196d");
52+
return new HDWalletProvider("private-key", "https://goerli.infura.io/v3/infura-key");
4753
},
4854
network_id: "5",
4955
},
50-
mainnet: {
56+
xdai: {
5157
provider: () => {
52-
return new HDWalletProvider("replace-with-private-key-when-using", "https://mainnet.infura.io/v3/e21146aa267845a2b7b4da025178196d");
58+
return new HDWalletProvider("private-key", "https://xdai-archive.blockscout.com/");
5359
},
54-
network_id: "1",
60+
network_id: "100",
5561
},
5662
storageSmoke: {
5763
provider: () => {

0 commit comments

Comments
 (0)