Skip to content

Commit

Permalink
modify rpc name
Browse files Browse the repository at this point in the history
  • Loading branch information
tjchern committed Aug 4, 2018
1 parent 45cfeaa commit c6d8adb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/tron/core/actuator/ActuatorFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ private static Actuator getActuatorByContract(Contract contract, Manager manager
return new BuyStorageBytesActuator(contract.getParameter(), manager);
case SellStorageContract:
return new SellStorageActuator(contract.getParameter(), manager);
case ConsumeUserResourcePercentContract:
return new ConsumeUserResourcePercentActuator(contract.getParameter(), manager);
case UpdateSettingContract:
return new UpdateSettingContractActuator(contract.getParameter(), manager);
default:

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
import org.tron.core.db.Manager;
import org.tron.core.exception.ContractExeException;
import org.tron.core.exception.ContractValidateException;
import org.tron.protos.Contract.ConsumeUserResourcePercentContract;
import org.tron.protos.Contract.UpdateSettingContract;
import org.tron.protos.Protocol.Transaction.Result.code;

@Slf4j
public class ConsumeUserResourcePercentActuator extends AbstractActuator {
public class UpdateSettingContractActuator extends AbstractActuator {

ConsumeUserResourcePercentActuator(Any contract, Manager dbManager) {
UpdateSettingContractActuator(Any contract, Manager dbManager) {
super(contract, dbManager);
}

@Override
public boolean execute(TransactionResultCapsule ret) throws ContractExeException {
long fee = calcFee();
try {
ConsumeUserResourcePercentContract curpContract = contract
.unpack(ConsumeUserResourcePercentContract.class);
long newPercent = curpContract.getConsumeUserResourcePercent();
byte[] contractAddress = curpContract.getContractAddress().toByteArray();
UpdateSettingContract usContract = contract
.unpack(UpdateSettingContract.class);
long newPercent = usContract.getConsumeUserResourcePercent();
byte[] contractAddress = usContract.getContractAddress().toByteArray();
ContractCapsule deployedContract = dbManager.getContractStore().get(contractAddress);

dbManager.getContractStore().put(contractAddress, new ContractCapsule(
Expand All @@ -55,15 +55,15 @@ public boolean validate() throws ContractValidateException {
if (this.dbManager == null) {
throw new ContractValidateException("No dbManager!");
}
if (!this.contract.is(ConsumeUserResourcePercentContract.class)) {
if (!this.contract.is(UpdateSettingContract.class)) {
throw new ContractValidateException(
"contract type error,expected type [ConsumeUserResourcePercentContract],real type["
"contract type error,expected type [UpdateSettingContract],real type["
+ contract
.getClass() + "]");
}
final ConsumeUserResourcePercentContract contract;
final UpdateSettingContract contract;
try {
contract = this.contract.unpack(ConsumeUserResourcePercentContract.class);
contract = this.contract.unpack(UpdateSettingContract.class);
} catch (InvalidProtocolBufferException e) {
logger.debug(e.getMessage(), e);
throw new ContractValidateException(e.getMessage());
Expand Down Expand Up @@ -109,7 +109,7 @@ public boolean validate() throws ContractValidateException {

@Override
public ByteString getOwnerAddress() throws InvalidProtocolBufferException {
return contract.unpack(ConsumeUserResourcePercentContract.class).getOwnerAddress();
return contract.unpack(UpdateSettingContract.class).getOwnerAddress();
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/tron/core/capsule/TransactionCapsule.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.tron.protos.Contract.AccountUpdateContract;
import org.tron.protos.Contract.BuyStorageBytesContract;
import org.tron.protos.Contract.BuyStorageContract;
import org.tron.protos.Contract.ConsumeUserResourcePercentContract;
import org.tron.protos.Contract.CreateSmartContract;
import org.tron.protos.Contract.FreezeBalanceContract;
import org.tron.protos.Contract.ParticipateAssetIssueContract;
Expand All @@ -58,6 +57,7 @@
import org.tron.protos.Contract.UnfreezeAssetContract;
import org.tron.protos.Contract.UnfreezeBalanceContract;
import org.tron.protos.Contract.UpdateAssetContract;
import org.tron.protos.Contract.UpdateSettingContract;
import org.tron.protos.Contract.WithdrawBalanceContract;
import org.tron.protos.Protocol.Transaction;
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
Expand Down Expand Up @@ -329,8 +329,8 @@ public static byte[] getOwner(Transaction.Contract contract) {
case SellStorageContract:
owner = contractParameter.unpack(SellStorageContract.class).getOwnerAddress();
break;
case ConsumeUserResourcePercentContract:
owner = contractParameter.unpack(ConsumeUserResourcePercentContract.class)
case UpdateSettingContract:
owner = contractParameter.unpack(UpdateSettingContract.class)
.getOwnerAddress();
break;
// todo add other contract
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/tron/core/services/RpcApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
import org.tron.protos.Contract;
import org.tron.protos.Contract.AccountCreateContract;
import org.tron.protos.Contract.AssetIssueContract;
import org.tron.protos.Contract.ConsumeUserResourcePercentContract;
import org.tron.protos.Contract.CreateSmartContract;
import org.tron.protos.Contract.ParticipateAssetIssueContract;
import org.tron.protos.Contract.TransferAssetContract;
import org.tron.protos.Contract.TransferContract;
import org.tron.protos.Contract.UnfreezeAssetContract;
import org.tron.protos.Contract.UpdateSettingContract;
import org.tron.protos.Contract.VoteWitnessContract;
import org.tron.protos.Contract.WitnessCreateContract;
import org.tron.protos.Protocol;
Expand Down Expand Up @@ -815,9 +815,9 @@ public void voteWitnessAccount2(VoteWitnessContract request,
}

@Override
public void modifyContractPercent(ConsumeUserResourcePercentContract request,
public void updateSetting(UpdateSettingContract request,
StreamObserver<TransactionExtention> responseObserver) {
createTransactionExtention(request, ContractType.ConsumeUserResourcePercentContract,
createTransactionExtention(request, ContractType.UpdateSettingContract,
responseObserver);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/protos/core/Tron.proto
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ message Transaction {
CreateSmartContract = 30;
TriggerSmartContract = 31;
GetContract = 32;
ConsumeUserResourcePercentContract = 33;
UpdateSettingContract = 33;
}
ContractType type = 1;
google.protobuf.Any parameter = 2;
Expand Down

0 comments on commit c6d8adb

Please sign in to comment.