Skip to content

Commit

Permalink
V3 support for Houston (RFC) (#909)
Browse files Browse the repository at this point in the history
Update for the RemoteControl to run with the latest Houston (v0.9.0).
  • Loading branch information
kipliklotrika authored and simonovic86 committed Apr 8, 2019
1 parent 7b3a7a7 commit 5264207
Show file tree
Hide file tree
Showing 27 changed files with 393 additions and 64 deletions.
12 changes: 12 additions & 0 deletions migrations/201807132355778-add-bids-dcidentity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

module.exports = {
up: async (queryInterface, Sequelize) =>
queryInterface.addColumn(
'bids',
'dc_identity',
{
type: Sequelize.STRING,
},
),
down: queryInterface => queryInterface.removeColumn('bids', 'dc_identity'),
};
1 change: 1 addition & 0 deletions models/bids.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = (sequelize, DataTypes) => {
offer_id: DataTypes.STRING,
data_set_id: DataTypes.STRING,
dc_node_id: DataTypes.STRING,
dc_identity: DataTypes.STRING,
data_size_in_bytes: DataTypes.STRING,
holding_time_in_minutes: DataTypes.INTEGER,
litigation_interval_in_minutes: DataTypes.INTEGER,
Expand Down
11 changes: 9 additions & 2 deletions modules/Blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ class Blockchain {
return this.blockchain.getTotalStakedAmount();
}

async getTotalIncome() {
return this.blockchain.getTotalIncome();
async getTotalPayouts(identity) {
return this.blockchain.getTotalPayouts(identity);
}

/**
Expand Down Expand Up @@ -568,6 +568,13 @@ class Blockchain {
async getHolderPaidAmount(offerId, holderIdentity) {
return this.blockchain.getHolderPaidAmount(offerId, holderIdentity);
}

/**
* Get litigation encryption type
*/
async getHolderLitigationEncryptionType(offerId, holderIdentity) {
return this.blockchain.getHolderLitigationEncryptionType(offerId, holderIdentity);
}
}

module.exports = Blockchain;
37 changes: 34 additions & 3 deletions modules/Blockchain/Ethereum/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const fs = require('fs');
const BN = require('bn.js');
const uuidv4 = require('uuid/v4');
const ethereumAbi = require('ethereumjs-abi');
const Op = require('sequelize/lib/operators');

const Transactions = require('./Transactions');
const Utilities = require('../../Utilities');
const Models = require('../../../models');
const Op = require('sequelize/lib/operators');
const uuidv4 = require('uuid/v4');
const ethereumAbi = require('ethereumjs-abi');

class Ethereum {
/**
Expand Down Expand Up @@ -1330,6 +1332,35 @@ class Ethereum {
from: this.config.wallet_address,
});
}

/**
* Get litigation encryption type
*/
async getHolderLitigationEncryptionType(offerId, holderIdentity) {
this.log.trace(`getHolderLitigationEncryptionType(offer=${offerId}, holderIdentity=${holderIdentity})`);
return this.holdingStorageContract.methods
.getHolderLitigationEncryptionType(offerId, holderIdentity).call({
from: this.config.wallet_address,
});
}

async getTotalPayouts(identity) {
const totalAmount = new BN(0);

const events = await this.contractsByName.HOLDING_CONTRACT.getPastEvents('PaidOut', {
fromBlock: 0,
toBlock: 'latest',
});
events.forEach((event) => {
if (Utilities.compareHexStrings(
event.returnValues.holder,
identity,
)) {
totalAmount.iadd(new BN(event.returnValues.amount));
}
});
return totalAmount.toString();
}
}

module.exports = Ethereum;
Loading

0 comments on commit 5264207

Please sign in to comment.