forked from Qortal/qortal
Fixed bug in name rebuilding.
This commit is contained in:
parent
6c201db3dd
commit
dac484136f
@ -107,7 +107,7 @@ public class NamesDatabaseIntegrityCheck {
|
||||
BuyNameTransactionData buyNameTransactionData = (BuyNameTransactionData) currentTransaction;
|
||||
Name nameObj = new Name(repository, buyNameTransactionData.getName());
|
||||
if (nameObj != null && nameObj.getNameData() != null) {
|
||||
nameObj.buy(buyNameTransactionData);
|
||||
nameObj.buy(buyNameTransactionData, false);
|
||||
modificationCount++;
|
||||
LOGGER.trace("Processed BUY_NAME transaction for name {}", name);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class Name {
|
||||
this.repository.getNameRepository().save(this.nameData);
|
||||
}
|
||||
|
||||
public void buy(BuyNameTransactionData buyNameTransactionData) throws DataException {
|
||||
public void buy(BuyNameTransactionData buyNameTransactionData, boolean modifyBalances) throws DataException {
|
||||
// Save previous name-changing reference in this transaction's data
|
||||
// Caller is expected to save
|
||||
buyNameTransactionData.setNameReference(this.nameData.getReference());
|
||||
@ -203,15 +203,20 @@ public class Name {
|
||||
// Mark not for-sale but leave price in case we want to orphan
|
||||
this.nameData.setIsForSale(false);
|
||||
|
||||
// Update seller's balance
|
||||
Account seller = new Account(this.repository, this.nameData.getOwner());
|
||||
seller.modifyAssetBalance(Asset.QORT, buyNameTransactionData.getAmount());
|
||||
if (modifyBalances) {
|
||||
// Update seller's balance
|
||||
Account seller = new Account(this.repository, this.nameData.getOwner());
|
||||
seller.modifyAssetBalance(Asset.QORT, buyNameTransactionData.getAmount());
|
||||
}
|
||||
|
||||
// Set new owner
|
||||
Account buyer = new PublicKeyAccount(this.repository, buyNameTransactionData.getBuyerPublicKey());
|
||||
this.nameData.setOwner(buyer.getAddress());
|
||||
// Update buyer's balance
|
||||
buyer.modifyAssetBalance(Asset.QORT, - buyNameTransactionData.getAmount());
|
||||
|
||||
if (modifyBalances) {
|
||||
// Update buyer's balance
|
||||
buyer.modifyAssetBalance(Asset.QORT, -buyNameTransactionData.getAmount());
|
||||
}
|
||||
|
||||
// Set name-changing reference to this transaction
|
||||
this.nameData.setReference(buyNameTransactionData.getSignature());
|
||||
|
@ -114,7 +114,7 @@ public class BuyNameTransaction extends Transaction {
|
||||
public void process() throws DataException {
|
||||
// Buy Name
|
||||
Name name = new Name(this.repository, this.buyNameTransactionData.getName());
|
||||
name.buy(this.buyNameTransactionData);
|
||||
name.buy(this.buyNameTransactionData, true);
|
||||
|
||||
// Save transaction with updated "name reference" pointing to previous transaction that changed name
|
||||
this.repository.getTransactionRepository().save(this.buyNameTransactionData);
|
||||
|
Loading…
x
Reference in New Issue
Block a user