- Automatically setting the bts_value column for BTS transfers.

This commit is contained in:
Nelson R. Perez 2019-02-03 18:13:00 -05:00
parent 85846b6c75
commit 262a0d58ad
2 changed files with 9 additions and 3 deletions

View file

@ -147,7 +147,6 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection {
mTransferViewModel.getTransferBlockNumberWithMissingTime().observe(this, Observer<Long>{ blockNumber -> mTransferViewModel.getTransferBlockNumberWithMissingTime().observe(this, Observer<Long>{ blockNumber ->
if (blockNumber != null && blockNumber != blockNumberWithMissingTime) { if (blockNumber != null && blockNumber != blockNumberWithMissingTime) {
blockNumberWithMissingTime = blockNumber blockNumberWithMissingTime = blockNumber
Log.d(TAG, "Block number: $blockNumber, Time: ${System.currentTimeMillis()}")
mHandler.post(mRequestBlockMissingTimeTask) mHandler.post(mRequestBlockMissingTimeTask)
} }
}) })
@ -251,7 +250,6 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection {
*/ */
private fun handleTransfersWithMissingBtsValue(transfer: Transfer) { private fun handleTransfersWithMissingBtsValue(transfer: Transfer) {
if(mNetworkService?.isConnected == true){ if(mNetworkService?.isConnected == true){
Log.d(TAG,"Transfer: ${transfer}")
val base = Asset(transfer.transferAssetId) val base = Asset(transfer.transferAssetId)
val quote = Asset("1.3.0") val quote = Asset("1.3.0")
val bucket: Long = TimeUnit.SECONDS.convert(1, TimeUnit.DAYS) val bucket: Long = TimeUnit.SECONDS.convert(1, TimeUnit.DAYS)
@ -373,7 +371,9 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection {
val disposable = Observable.just(pair) val disposable = Observable.just(pair)
.subscribeOn(Schedulers.computation()) .subscribeOn(Schedulers.computation())
.map { mTransferViewModel.updateBtsValue(it.first!!, it.second) } .map { mTransferViewModel.updateBtsValue(it.first!!, it.second) }
.subscribe({},{ Log.e(TAG,"Error at updateBtsValue. Msg: ${it.message}") .subscribe({},{
Log.e(TAG,"Error at updateBtsValue. Msg: ${it.message}")
for(line in it.stackTrace) Log.e(TAG, "${line.className}#${line.methodName}:${line.lineNumber}")
}) })
mCompositeDisposable.add(disposable) mCompositeDisposable.add(disposable)
}else{ }else{

View file

@ -25,4 +25,10 @@ data class Transfer (
// Constant used to specify a BTS equivalent value whose calculation returned an error // Constant used to specify a BTS equivalent value whose calculation returned an error
val ERROR: Long? = -2L val ERROR: Long? = -2L
} }
init {
if(transferAssetId.equals("1.3.0")){
// If the transferred asset is BTS, we can fill the btsValue field immediately
btsValue = transferAmount
}
}
} }