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