@@ -132,14 +132,17 @@ func (db *MongoDbBridge) isUniqueWithdrawRequest(col *mongo.Collection, wr *type
132132// shiftClosedWithdrawRequest updates a request ID of an existing withdraw request to preserve requests
133133// history if the withdraw request is already closed.
134134func (db * MongoDbBridge ) shiftClosedWithdrawRequest (col * mongo.Collection , wr * types.WithdrawRequest ) (bool , error ) {
135+ // generate new ID
136+ reqID := (* hexutil .Big )(new (big.Int ).SetBytes (wr .RequestTrx .Bytes ()[:16 ])).String ()
137+
135138 // try to shift a closed withdraw request to a different reqID by updating it in the database
136139 er , err := col .UpdateOne (context .Background (), bson.D {
137140 {types .FiWithdrawalAddress , wr .Address .String ()},
138141 {types .FiWithdrawalToValidator , wr .StakerID .String ()},
139142 {types .FiWithdrawalRequestID , wr .WithdrawRequestID .String ()},
140143 {types .FiWithdrawalFinTime , bson.D {{"$exists" , true }, {"$ne" , nil }}},
141144 }, bson.D {{"$set" , bson.D {
142- {types .FiWithdrawalRequestID , wr . RequestTrx . String () },
145+ {types .FiWithdrawalRequestID , reqID },
143146 }}}, new (options.UpdateOptions ).SetUpsert (true ))
144147 if err != nil {
145148 db .log .Criticalf ("can not shift withdrawal; %s" , err .Error ())
@@ -152,10 +155,11 @@ func (db *MongoDbBridge) shiftClosedWithdrawRequest(col *mongo.Collection, wr *t
152155 }
153156
154157 // shift successful, log what we did
155- db .log .Infof ("shifted withdrawal by %s to %d, request ID %s, by trx %s " ,
158+ db .log .Infof ("shifted withdrawal request ID %s to %s of delegation %s to %d " ,
156159 wr .Address .String (),
157160 wr .StakerID .ToInt ().Uint64 (),
158161 wr .WithdrawRequestID .String (),
162+ reqID ,
159163 wr .RequestTrx .String ())
160164 return true , nil
161165}
0 commit comments