if ii, ok := orig.TypedInput.(*types.IssuanceInput); ok {
if isValidJSON(ii.AssetDefinition) {
assetID := ii.AssetID()
- if assetExist := walletDB.Get(asset.CalcExtAssetKey(&assetID)); assetExist != nil {
- continue
+ if assetExist := walletDB.Get(asset.CalcExtAssetKey(&assetID)); assetExist == nil {
+ storeBatch.Set(asset.CalcExtAssetKey(&assetID), ii.AssetDefinition)
}
- storeBatch.Set(asset.CalcExtAssetKey(&assetID), ii.AssetDefinition)
}
}
}
// GetTransactionsByTxID get account txs by account tx ID
func (w *Wallet) GetTransactionsByTxID(txID string) ([]*query.AnnotatedTx, error) {
- annotatedTxs := []*query.AnnotatedTx{}
+ var annotatedTxs []*query.AnnotatedTx
formatKey := ""
if txID != "" {
formatKey = string(rawFormatKey)
}
- txIter := w.DB.IteratorPrefix([]byte(TxPrefix + formatKey))
+ txIter := w.DB.IteratorPrefix(calcAnnotatedKey(formatKey))
defer txIter.Release()
for txIter.Next() {
annotatedTx := &query.AnnotatedTx{}
annotatedTxs = append(annotatedTxs, annotatedTx)
}
+ // reverse annotatedTxs
+ for i, j := 0, len(annotatedTxs) - 1; i < j; i, j = i + 1, j - 1 {
+ annotatedTxs[i], annotatedTxs[j] = annotatedTxs[j], annotatedTxs[i]
+ }
+
return annotatedTxs, nil
}