|
4 | 4 | "context"
|
5 | 5 |
|
6 | 6 | "go.mongodb.org/mongo-driver/bson"
|
| 7 | + "go.mongodb.org/mongo-driver/bson/primitive" |
7 | 8 | "go.mongodb.org/mongo-driver/mongo"
|
8 | 9 | "go.mongodb.org/mongo-driver/mongo/options"
|
9 | 10 |
|
@@ -112,35 +113,35 @@ func (db *Database) FindSendUnbondingDocuments(ctx context.Context) ([]model.Unb
|
112 | 113 |
|
113 | 114 | func (db *Database) updateUnbondingDocumentState(
|
114 | 115 | ctx context.Context,
|
115 |
| - unbondingTxHashHex string, |
| 116 | + id primitive.ObjectID, |
116 | 117 | newState model.UnbondingState) error {
|
117 | 118 | client := db.Client.Database(db.DbName).Collection(model.UnbondingCollection)
|
118 |
| - filter := bson.M{"unbonding_tx_hash_hex": unbondingTxHashHex} |
| 119 | + filter := bson.M{"_id": id} |
119 | 120 | update := bson.M{"$set": bson.M{"state": newState}}
|
120 | 121 | _, err := client.UpdateOne(ctx, filter, update)
|
121 | 122 | return err
|
122 | 123 | }
|
123 | 124 |
|
124 | 125 | func (db *Database) SetUnbondingDocumentSend(
|
125 | 126 | ctx context.Context,
|
126 |
| - unbondingTxHashHex string) error { |
127 |
| - return db.updateUnbondingDocumentState(ctx, unbondingTxHashHex, model.Send) |
| 127 | + id primitive.ObjectID) error { |
| 128 | + return db.updateUnbondingDocumentState(ctx, id, model.Send) |
128 | 129 | }
|
129 | 130 |
|
130 | 131 | func (db *Database) SetUnbondingDocumentFailed(
|
131 | 132 | ctx context.Context,
|
132 |
| - unbondingTxHashHex string) error { |
133 |
| - return db.updateUnbondingDocumentState(ctx, unbondingTxHashHex, model.Failed) |
| 133 | + id primitive.ObjectID) error { |
| 134 | + return db.updateUnbondingDocumentState(ctx, id, model.Failed) |
134 | 135 | }
|
135 | 136 |
|
136 | 137 | func (db *Database) SetUnbondingDocumentInputAlreadySpent(
|
137 | 138 | ctx context.Context,
|
138 |
| - unbondingTxHashHex string) error { |
139 |
| - return db.updateUnbondingDocumentState(ctx, unbondingTxHashHex, model.InputAlreadySpent) |
| 139 | + id primitive.ObjectID) error { |
| 140 | + return db.updateUnbondingDocumentState(ctx, id, model.InputAlreadySpent) |
140 | 141 | }
|
141 | 142 |
|
142 | 143 | func (db *Database) SetUnbondingDocumentFailedToGetCovenantSignatures(
|
143 | 144 | ctx context.Context,
|
144 |
| - unbondingTxHashHex string) error { |
145 |
| - return db.updateUnbondingDocumentState(ctx, unbondingTxHashHex, model.FailedToGetCovenantSignatures) |
| 145 | + id primitive.ObjectID) error { |
| 146 | + return db.updateUnbondingDocumentState(ctx, id, model.FailedToGetCovenantSignatures) |
146 | 147 | }
|
0 commit comments