Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dutch_auction' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
457813723 committed Nov 20, 2023
2 parents 36315a2 + 68722f0 commit 3702a60
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
17 changes: 16 additions & 1 deletion block_parser/action_account_cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,22 @@ func (b *BlockParser) ActionBidExpiredAccountAuction(req FuncTransactionHandleRe
}
log.Info("ActionBidExpiredAccountAuction:", accountInfo)

if err := b.dbDao.BidExpiredAccountAuction(accountInfo, transactionInfos); err != nil {
var recordsInfos []dao.TableRecordsInfo

recordList := builder.Records
for _, v := range recordList {
recordsInfos = append(recordsInfos, dao.TableRecordsInfo{
AccountId: accountId,
Account: account,
Key: v.Key,
Type: v.Type,
Label: v.Label,
Value: v.Value,
Ttl: strconv.FormatUint(uint64(v.TTL), 10),
})
}

if err := b.dbDao.BidExpiredAccountAuction(accountInfo, recordsInfos, transactionInfos); err != nil {
log.Error("ActionBidExpiredAccountAuction err:", err.Error(), toolib.JsonString(accountInfo))
resp.Err = fmt.Errorf("ActionBidExpiredAccountAuction err: %s", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion block_parser/block_parser_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (b *BlockParser) registerTransactionHandle() {
b.mapTransactionHandle[common.DasActionDelayApproval] = b.DasActionDelayApproval
b.mapTransactionHandle[common.DasActionRevokeApproval] = b.DasActionRevokeApproval
b.mapTransactionHandle[common.DasActionFulfillApproval] = b.DasActionFulfillApproval
b.mapTransactionHandle[common.DasBidExpiredAccountAuction] = b.ActionBidExpiredAccountAuction
b.mapTransactionHandle[common.DasActionBidExpiredAccountAuction] = b.ActionBidExpiredAccountAuction

}

Expand Down
8 changes: 7 additions & 1 deletion dao/dao_account_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (d *DbDao) GetAccountInfoByParentAccountId(parentAccountId string) (account
return
}

func (d *DbDao) BidExpiredAccountAuction(accountInfo TableAccountInfo, transactionInfos []TableTransactionInfo) error {
func (d *DbDao) BidExpiredAccountAuction(accountInfo TableAccountInfo, recordsInfos []TableRecordsInfo, transactionInfos []TableTransactionInfo) error {
return d.db.Transaction(func(tx *gorm.DB) error {
//update account_info
if err := tx.Select("expired_at", "registered_at", "block_number", "outpoint", "owner_chain_type", "owner", "owner_algorithm_id", "owner_sub_aid", "manager_chain_type", "manager", "manager_algorithm_id", "manager_sub_aid").
Expand All @@ -268,6 +268,12 @@ func (d *DbDao) BidExpiredAccountAuction(accountInfo TableAccountInfo, transacti
if err := tx.Where("account_id=?", accountInfo.AccountId).Delete(&TableRecordsInfo{}).Error; err != nil {
return err
}
//default record
if len(recordsInfos) > 0 {
if err := tx.Create(&recordsInfos).Error; err != nil {
return err
}
}
return nil
})
}
Expand Down

0 comments on commit 3702a60

Please sign in to comment.