- Fixing inconsistent loading of transactions
This commit is contained in:
parent
d549e3af8d
commit
270f2d40b6
4 changed files with 66 additions and 28 deletions
|
@ -1,6 +1,7 @@
|
||||||
package cy.agorise.crystalwallet.apigenerator;
|
package cy.agorise.crystalwallet.apigenerator;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -380,10 +381,20 @@ public abstract class GrapheneApiGenerator {
|
||||||
public void success(Object answer, int idPetition) {
|
public void success(Object answer, int idPetition) {
|
||||||
ArrayList<BitsharesAsset> assets = (ArrayList<BitsharesAsset>) answer;
|
ArrayList<BitsharesAsset> assets = (ArrayList<BitsharesAsset>) answer;
|
||||||
for(BitsharesAsset asset : assets){
|
for(BitsharesAsset asset : assets){
|
||||||
|
|
||||||
|
long currencyId = -1;
|
||||||
|
CryptoCurrency cryptoCurrencyDb = cryptoCurrencyDao.getByNameAndCryptoNet(((BitsharesAsset) answer).getName(),((BitsharesAsset) answer).getCryptoNet().name());
|
||||||
|
|
||||||
|
if (cryptoCurrencyDb != null){
|
||||||
|
currencyId = cryptoCurrencyDb.getId();
|
||||||
|
} else {
|
||||||
long idCryptoCurrency = cryptoCurrencyDao.insertCryptoCurrency(asset)[0];
|
long idCryptoCurrency = cryptoCurrencyDao.insertCryptoCurrency(asset)[0];
|
||||||
|
currencyId = idCryptoCurrency;
|
||||||
|
}
|
||||||
|
|
||||||
BitsharesAssetInfo info = new BitsharesAssetInfo(asset);
|
BitsharesAssetInfo info = new BitsharesAssetInfo(asset);
|
||||||
info.setCryptoCurrencyId(idCryptoCurrency);
|
info.setCryptoCurrencyId(currencyId);
|
||||||
asset.setId((int)idCryptoCurrency);
|
asset.setId((int)currencyId);
|
||||||
bitsharesAssetDao.insertBitsharesAssetInfo(info);
|
bitsharesAssetDao.insertBitsharesAssetInfo(info);
|
||||||
saveTransaction(transaction,cryptoCurrencyDao.getById(info.getCryptoCurrencyId()),accountBitsharesId,tOperation,context);
|
saveTransaction(transaction,cryptoCurrencyDao.getById(info.getCryptoCurrencyId()),accountBitsharesId,tOperation,context);
|
||||||
}
|
}
|
||||||
|
@ -484,10 +495,19 @@ public abstract class GrapheneApiGenerator {
|
||||||
List<BitsharesAsset> assets = (List<BitsharesAsset>) answer;
|
List<BitsharesAsset> assets = (List<BitsharesAsset>) answer;
|
||||||
for(BitsharesAsset asset : assets) {
|
for(BitsharesAsset asset : assets) {
|
||||||
BitsharesAssetInfo info = new BitsharesAssetInfo(asset);
|
BitsharesAssetInfo info = new BitsharesAssetInfo(asset);
|
||||||
|
|
||||||
|
long currencyId = -1;
|
||||||
|
CryptoCurrency cryptoCurrencyDb = cryptoCurrencyDao.getByNameAndCryptoNet(asset.getName(),asset.getCryptoNet().name());
|
||||||
|
|
||||||
|
if (cryptoCurrencyDb != null){
|
||||||
|
currencyId = cryptoCurrencyDb.getId();
|
||||||
|
} else {
|
||||||
long[] cryptoCurrencyId = cryptoCurrencyDao.insertCryptoCurrency((CryptoCurrency) asset);
|
long[] cryptoCurrencyId = cryptoCurrencyDao.insertCryptoCurrency((CryptoCurrency) asset);
|
||||||
info.setCryptoCurrencyId(cryptoCurrencyId[0]);
|
currencyId = cryptoCurrencyId[0];
|
||||||
|
}
|
||||||
|
info.setCryptoCurrencyId(currencyId);
|
||||||
bitsharesAssetDao.insertBitsharesAssetInfo(info);
|
bitsharesAssetDao.insertBitsharesAssetInfo(info);
|
||||||
ccBalance.setCryptoCurrencyId(cryptoCurrencyId[0]);
|
ccBalance.setCryptoCurrencyId(currencyId);
|
||||||
balanceDao.insertCryptoCoinBalance(ccBalance);
|
balanceDao.insertCryptoCoinBalance(ccBalance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,8 +636,18 @@ public abstract class GrapheneApiGenerator {
|
||||||
public void success(Object answer, int idPetition) {
|
public void success(Object answer, int idPetition) {
|
||||||
if(answer instanceof BitsharesAsset){
|
if(answer instanceof BitsharesAsset){
|
||||||
BitsharesAssetInfo info = new BitsharesAssetInfo((BitsharesAsset) answer);
|
BitsharesAssetInfo info = new BitsharesAssetInfo((BitsharesAsset) answer);
|
||||||
|
|
||||||
|
long currencyId = -1;
|
||||||
|
CryptoCurrency cryptoCurrencyDb = cryptoCurrencyDao.getByNameAndCryptoNet(((BitsharesAsset) answer).getName(),((BitsharesAsset) answer).getCryptoNet().name());
|
||||||
|
|
||||||
|
if (cryptoCurrencyDb != null){
|
||||||
|
currencyId = cryptoCurrencyDb.getId();
|
||||||
|
} else {
|
||||||
long cryptoCurrencyId = cryptoCurrencyDao.insertCryptoCurrency((CryptoCurrency)answer )[0];
|
long cryptoCurrencyId = cryptoCurrencyDao.insertCryptoCurrency((CryptoCurrency)answer )[0];
|
||||||
info.setCryptoCurrencyId(cryptoCurrencyId);
|
currencyId = cryptoCurrencyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
info.setCryptoCurrencyId(currencyId);
|
||||||
bitsharesAssetDao.insertBitsharesAssetInfo(info);
|
bitsharesAssetDao.insertBitsharesAssetInfo(info);
|
||||||
GrapheneApiGenerator.getEquivalentValue((BitsharesAsset) answer, quoteAssets, context);
|
GrapheneApiGenerator.getEquivalentValue((BitsharesAsset) answer, quoteAssets, context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,6 @@ public interface BitsharesAssetDao {
|
||||||
@Query("SELECT * FROM bitshares_asset WHERE bitshares_id = :bitsharesId")
|
@Query("SELECT * FROM bitshares_asset WHERE bitshares_id = :bitsharesId")
|
||||||
BitsharesAssetInfo getBitsharesAssetInfoById(String bitsharesId);
|
BitsharesAssetInfo getBitsharesAssetInfoById(String bitsharesId);
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
public long[] insertBitsharesAssetInfo(BitsharesAssetInfo... accounts);
|
public long[] insertBitsharesAssetInfo(BitsharesAssetInfo... accounts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public interface CryptoCurrencyDao {
|
||||||
@Query("SELECT * FROM crypto_currency WHERE name = :name")
|
@Query("SELECT * FROM crypto_currency WHERE name = :name")
|
||||||
CryptoCurrency getByName(String name);
|
CryptoCurrency getByName(String name);
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
public long[] insertCryptoCurrency(CryptoCurrency... currencies);
|
public long[] insertCryptoCurrency(CryptoCurrency... currencies);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,8 +348,6 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
createRequest.setStatus(ValidateCreateBitsharesAccountRequest.StatusCode.ACCOUNT_EXIST);
|
createRequest.setStatus(ValidateCreateBitsharesAccountRequest.StatusCode.ACCOUNT_EXIST);
|
||||||
}
|
}
|
||||||
}, context);
|
}, context);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -681,10 +679,20 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
public void success(Object answer, int idPetition) {
|
public void success(Object answer, int idPetition) {
|
||||||
ArrayList<BitsharesAsset> assets = (ArrayList<BitsharesAsset>) answer;
|
ArrayList<BitsharesAsset> assets = (ArrayList<BitsharesAsset>) answer;
|
||||||
for(BitsharesAsset asset : assets){
|
for(BitsharesAsset asset : assets){
|
||||||
|
long currencyId = -1;
|
||||||
|
CryptoCurrency cryptoCurrencyDb = db.cryptoCurrencyDao().getByNameAndCryptoNet(asset.getName(),asset.getCryptoNet().name());
|
||||||
|
|
||||||
|
if (cryptoCurrencyDb != null){
|
||||||
|
currencyId = cryptoCurrencyDb.getId();
|
||||||
|
} else {
|
||||||
long idCryptoCurrency = db.cryptoCurrencyDao().insertCryptoCurrency(asset)[0];
|
long idCryptoCurrency = db.cryptoCurrencyDao().insertCryptoCurrency(asset)[0];
|
||||||
|
currencyId = idCryptoCurrency;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BitsharesAssetInfo info = new BitsharesAssetInfo(asset);
|
BitsharesAssetInfo info = new BitsharesAssetInfo(asset);
|
||||||
info.setCryptoCurrencyId(idCryptoCurrency);
|
info.setCryptoCurrencyId(currencyId);
|
||||||
asset.setId((int)idCryptoCurrency);
|
asset.setId((int)currencyId);
|
||||||
db.bitsharesAssetDao().insertBitsharesAssetInfo(info);
|
db.bitsharesAssetDao().insertBitsharesAssetInfo(info);
|
||||||
saveTransaction(transaction,info,transfer);
|
saveTransaction(transaction,info,transfer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue