mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 10:22:18 +01:00
Add voting parameters
This commit is contained in:
parent
7a813961f9
commit
4cbd0f8966
@ -21,6 +21,7 @@ import com.google.inject.Singleton;
|
||||
import io.bitsquare.app.AppModule;
|
||||
import io.bitsquare.dao.compensation.CompensationRequestManager;
|
||||
import io.bitsquare.dao.vote.VoteManager;
|
||||
import io.bitsquare.dao.vote.VotingParameters;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
@ -36,6 +37,7 @@ public class DaoModule extends AppModule {
|
||||
protected void configure() {
|
||||
bind(CompensationRequestManager.class).in(Singleton.class);
|
||||
bind(VoteManager.class).in(Singleton.class);
|
||||
bind(VotingParameters.class).in(Singleton.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public final class CompensationRequestVoteItemCollection extends VoteItem implem
|
||||
}
|
||||
|
||||
|
||||
public CompensationRequestVoteItemCollection(VotingCodes.Code code, String name) {
|
||||
public CompensationRequestVoteItemCollection(VotingParameters.Code code, String name) {
|
||||
super(code, name);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class VoteItem implements Persistable {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(VoteItem.class);
|
||||
// public final String version;
|
||||
public final VotingCodes.Code code;
|
||||
public final VotingParameters.Code code;
|
||||
public final String name;
|
||||
protected boolean hasVoted;
|
||||
|
||||
@ -39,13 +39,13 @@ public class VoteItem implements Persistable {
|
||||
|
||||
private byte value;
|
||||
|
||||
public VoteItem(VotingCodes.Code code, String name, byte value) {
|
||||
public VoteItem(VotingParameters.Code code, String name, byte value) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public VoteItem(VotingCodes.Code code, String name) {
|
||||
public VoteItem(VotingParameters.Code code, String name) {
|
||||
this(code, name, (byte) 0x00);
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,10 @@ public final class VoteItemCollection extends ArrayList<VoteItem> implements Per
|
||||
private boolean isMyVote;
|
||||
|
||||
public VoteItemCollection() {
|
||||
add(new VoteItem(VotingCodes.Code.CREATE_OFFER_FEE, "Create offer fee", (byte) 0));
|
||||
add(new VoteItem(VotingCodes.Code.TAKE_OFFER_FEE, "Take offer fee", (byte) 0));
|
||||
add(new VoteItem(VotingCodes.Code.PERIOD_UNTIL_NEXT_VOTING, "Period until next voting", (byte) 0));
|
||||
add(new CompensationRequestVoteItemCollection(VotingCodes.Code.COMP_REQUEST_MAPS, "CompensationRequest"));
|
||||
add(new VoteItem(VotingParameters.Code.CREATE_OFFER_FEE_IN_BTC, "Create offer fee", (byte) 0));
|
||||
add(new VoteItem(VotingParameters.Code.TAKE_OFFER_FEE_IN_BTC, "Take offer fee", (byte) 0));
|
||||
add(new VoteItem(VotingParameters.Code.COMPENSATION_REQUEST_PERIOD_IN_BLOCKS, "Period until next voting", (byte) 0));
|
||||
add(new CompensationRequestVoteItemCollection(VotingParameters.Code.COMP_REQUEST_MAPS, "CompensationRequest"));
|
||||
}
|
||||
|
||||
public void setIsMyVote(boolean isMyVote) {
|
||||
|
@ -101,9 +101,6 @@ public class VoteManager {
|
||||
checkArgument(itemOptional.get() instanceof CompensationRequestVoteItemCollection,
|
||||
"Item must be CompensationRequestVoteItemCollection");
|
||||
CompensationRequestVoteItemCollection collection = (CompensationRequestVoteItemCollection) itemOptional.get();
|
||||
int payloadSize = collection.code.payloadSize;
|
||||
checkArgument(payloadSize == 2, "payloadSize for CompensationRequestVoteItemCollection must be 2. " +
|
||||
"We got payloadSize=" + payloadSize);
|
||||
List<CompensationRequestVoteItem> items = collection.getCompensationRequestVoteItemsSortedByTxId();
|
||||
int itemsSize = items.size();
|
||||
// We have max 39 bytes space ((80 - 20 - 2) / 2 = 29). 29 bytes are 232 bits/items to vote on
|
||||
@ -165,9 +162,6 @@ public class VoteManager {
|
||||
checkArgument(outputStream.size() % 2 == 0,
|
||||
"Position of writing code must be at even index.");
|
||||
outputStream.write(paramItem.code.code);
|
||||
int payloadSize = paramItem.code.payloadSize;
|
||||
checkArgument(payloadSize == 1,
|
||||
"payloadSize is not as expected(4). payloadSize=" + payloadSize);
|
||||
byte value = paramItem.getValue();
|
||||
outputStream.write(value);
|
||||
});
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.dao.vote;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class VotingCodes {
|
||||
private static final Logger log = LoggerFactory.getLogger(VotingCodes.class);
|
||||
|
||||
public enum Code {
|
||||
COMP_REQUEST_MAPS((byte) 0x01, 2),
|
||||
CREATE_OFFER_FEE((byte) 0x11, 1),
|
||||
TAKE_OFFER_FEE((byte) 0x12, 1),
|
||||
PERIOD_UNTIL_NEXT_VOTING((byte) 0x20, 1);
|
||||
|
||||
public final Byte code;
|
||||
public final int payloadSize;
|
||||
|
||||
Code(Byte code, int payloadSize) {
|
||||
this.code = code;
|
||||
this.payloadSize = payloadSize;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
215
core/src/main/java/io/bitsquare/dao/vote/VotingParameters.java
Normal file
215
core/src/main/java/io/bitsquare/dao/vote/VotingParameters.java
Normal file
@ -0,0 +1,215 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.dao.vote;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class VotingParameters {
|
||||
private static final Logger log = LoggerFactory.getLogger(VotingParameters.class);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enums
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public enum Code {
|
||||
CREATE_OFFER_FEE_IN_BTC((byte) 0x01),
|
||||
TAKE_OFFER_FEE_IN_BTC((byte) 0x02),
|
||||
CREATE_OFFER_FEE_IN_SQU((byte) 0x03),
|
||||
TAKE_OFFER_FEE_IN_SQU((byte) 0x04),
|
||||
CREATE_COMPENSATION_REQUEST_FEE_IN_SQU((byte) 0x05),
|
||||
VOTING_FEE_IN_SQU((byte) 0x06),
|
||||
|
||||
COMPENSATION_REQUEST_PERIOD_IN_BLOCKS((byte) 0x10),
|
||||
VOTING_PERIOD_IN_BLOCKS((byte) 0x11),
|
||||
FUNDING_PERIOD_IN_BLOCKS((byte) 0x12),
|
||||
BREAK_BETWEEN_PERIODS_IN_BLOCKS((byte) 0x13),
|
||||
|
||||
QUORUM_FOR_COMPENSATION_REQUEST_VOTING((byte) 0x20),
|
||||
QUORUM_FOR_PARAMETER_VOTING((byte) 0x21),
|
||||
|
||||
MIN_BTC_AMOUNT_COMPENSATION_REQUEST((byte) 0x30),
|
||||
MAX_BTC_AMOUNT_COMPENSATION_REQUEST((byte) 0x31),
|
||||
|
||||
COMP_REQUEST_MAPS((byte) 0x40);
|
||||
|
||||
public final Byte code;
|
||||
|
||||
Code(Byte code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Fields
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private long createOfferFeeInBtc = 30_000;
|
||||
private long takeOfferFeeInBtc = 80_000;
|
||||
|
||||
private long createOfferFeeInSqu = 333;
|
||||
private long takeOfferFeeInSqu = 444;
|
||||
|
||||
private long createCompensationRequestFeeInSqu = 7777;
|
||||
private long votingFeeInSqu = 8888;
|
||||
|
||||
private double conversionRate = 0.000001; // how many btc you get for 1 squ (e.g. 1 000 000 squ = 1 btc)
|
||||
|
||||
// 144 blocks is 1 day
|
||||
private long compensationRequestPeriodInBlocks = 2880; // 20 days
|
||||
private long votingPeriodInBlocks = 432; // 3 days
|
||||
private long fundingPeriodInBlocks = 1008; // 7 days
|
||||
private long breakBetweenPeriodsInBlocks = 10;
|
||||
|
||||
private double quorumForCompensationRequestVoting = 5; // 5%
|
||||
private double quorumForParameterVoting = 5; // 5%
|
||||
|
||||
private long minBtcAmountCompensationRequest = 20_000_000; // 0.2 BTC
|
||||
private long maxBtcAmountCompensationRequest = 2_000_000_000; // 20 btc
|
||||
|
||||
private boolean voteResultsApplied;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public VotingParameters() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters/Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public boolean getVoteResultsApplied() {
|
||||
return voteResultsApplied;
|
||||
}
|
||||
|
||||
public void setVoteResultsApplied(boolean voteResultsApplied) {
|
||||
this.voteResultsApplied = voteResultsApplied;
|
||||
}
|
||||
|
||||
public long getMaxBtcAmountCompensationRequest() {
|
||||
return maxBtcAmountCompensationRequest;
|
||||
}
|
||||
|
||||
public void setMaxBtcAmountCompensationRequest(long maxBtcAmountCompensationRequest) {
|
||||
this.maxBtcAmountCompensationRequest = maxBtcAmountCompensationRequest;
|
||||
}
|
||||
|
||||
public long getCreateOfferFeeInBtc() {
|
||||
return createOfferFeeInBtc;
|
||||
}
|
||||
|
||||
public void setCreateOfferFeeInBtc(long createOfferFeeInBtc) {
|
||||
this.createOfferFeeInBtc = createOfferFeeInBtc;
|
||||
}
|
||||
|
||||
public long getTakeOfferFeeInBtc() {
|
||||
return takeOfferFeeInBtc;
|
||||
}
|
||||
|
||||
public void setTakeOfferFeeInBtc(long takeOfferFeeInBtc) {
|
||||
this.takeOfferFeeInBtc = takeOfferFeeInBtc;
|
||||
}
|
||||
|
||||
public long getCreateCompensationRequestFeeInSqu() {
|
||||
return createCompensationRequestFeeInSqu;
|
||||
}
|
||||
|
||||
public void setCreateCompensationRequestFeeInSqu(long createCompensationRequestFeeInSqu) {
|
||||
this.createCompensationRequestFeeInSqu = createCompensationRequestFeeInSqu;
|
||||
}
|
||||
|
||||
public long getVotingFeeInSqu() {
|
||||
return votingFeeInSqu;
|
||||
}
|
||||
|
||||
public void setVotingFeeInSqu(long votingFeeInSqu) {
|
||||
this.votingFeeInSqu = votingFeeInSqu;
|
||||
}
|
||||
|
||||
public double getConversionRate() {
|
||||
return conversionRate;
|
||||
}
|
||||
|
||||
public void setConversionRate(double conversionRate) {
|
||||
this.conversionRate = conversionRate;
|
||||
}
|
||||
|
||||
public long getCompensationRequestPeriodInBlocks() {
|
||||
return compensationRequestPeriodInBlocks;
|
||||
}
|
||||
|
||||
public void setCompensationRequestPeriodInBlocks(long compensationRequestPeriodInBlocks) {
|
||||
this.compensationRequestPeriodInBlocks = compensationRequestPeriodInBlocks;
|
||||
}
|
||||
|
||||
public long getVotingPeriodInBlocks() {
|
||||
return votingPeriodInBlocks;
|
||||
}
|
||||
|
||||
public void setVotingPeriodInBlocks(long votingPeriodInBlocks) {
|
||||
this.votingPeriodInBlocks = votingPeriodInBlocks;
|
||||
}
|
||||
|
||||
public long getFundingPeriodInBlocks() {
|
||||
return fundingPeriodInBlocks;
|
||||
}
|
||||
|
||||
public void setFundingPeriodInBlocks(long fundingPeriodInBlocks) {
|
||||
this.fundingPeriodInBlocks = fundingPeriodInBlocks;
|
||||
}
|
||||
|
||||
public long getBreakBetweenPeriodsInBlocks() {
|
||||
return breakBetweenPeriodsInBlocks;
|
||||
}
|
||||
|
||||
public void setBreakBetweenPeriodsInBlocks(long breakBetweenPeriodsInBlocks) {
|
||||
this.breakBetweenPeriodsInBlocks = breakBetweenPeriodsInBlocks;
|
||||
}
|
||||
|
||||
public double getQuorumForCompensationRequestVoting() {
|
||||
return quorumForCompensationRequestVoting;
|
||||
}
|
||||
|
||||
public void setQuorumForCompensationRequestVoting(double quorumForCompensationRequestVoting) {
|
||||
this.quorumForCompensationRequestVoting = quorumForCompensationRequestVoting;
|
||||
}
|
||||
|
||||
public double getQuorumForParameterVoting() {
|
||||
return quorumForParameterVoting;
|
||||
}
|
||||
|
||||
public void setQuorumForParameterVoting(double quorumForParameterVoting) {
|
||||
this.quorumForParameterVoting = quorumForParameterVoting;
|
||||
}
|
||||
|
||||
public long getMinBtcAmountCompensationRequest() {
|
||||
return minBtcAmountCompensationRequest;
|
||||
}
|
||||
|
||||
public void setMinBtcAmountCompensationRequest(long minBtcAmountCompensationRequest) {
|
||||
this.minBtcAmountCompensationRequest = minBtcAmountCompensationRequest;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user