import (
// "time"
+ "encoding/json"
// "github.com/bytom/errors"
// "github.com/bytom/protocol/bc"
log.WithField("err", err).Fatal("subscribe new transaction fail")
}
- // u.receiveTransactions()
+ u.receiveTransactions()
+}
+
+// TODO: FK
+type TxDesc struct {
+ // Tx *btmTypes.Tx `json:"transaction"`
+ StatusFail bool `json:"status_fail"`
+}
+
+func (u *unconfirmedTxKeeper) receiveTransactions() {
+ for resp := range u.processTxCh {
+ if resp.NotificationType != service.ResponseNewTransaction {
+ log.Warn("receive non new transaction message")
+ continue
+ }
+
+ txDesc := &TxDesc{}
+ if err := json.Unmarshal([]byte(resp.Data), txDesc); err != nil {
+ log.WithField("err", err).Error("unmarshal transaction error")
+ continue
+ }
+
+ // coin := &orm.Coin{Name: u.coinName}
+ // if err := u.db.Where(coin).First(coin).Error; err != nil {
+ // log.WithField("err", err).Error("query coin fail")
+ // continue
+ // }
+
+ // if err := addIssueAssets(u.db, []*btmTypes.Tx{txDesc.Tx}, coin.ID); err != nil {
+ // log.WithField("err", err).Error("fail on adding issue assets")
+ // }
+
+ // if err := u.AddUnconfirmedTx(coin, txDesc); err != nil {
+ // log.WithField("err", err).Error("fail on adding unconfirmed transaction")
+ // }
+ }
}