@riocrypto/common-server 1.0.2884 → 1.0.2886

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,6 +66,10 @@ interface InternalTransferDoc extends mongoose.Document {
66
66
  };
67
67
  amount: number;
68
68
  currency: Fiat | Crypto;
69
+ counterpartyLookup?: {
70
+ attempts: number;
71
+ nextAttemptAt: Date;
72
+ };
69
73
  }
70
74
  interface InternalTransferModel extends mongoose.Model<InternalTransferDoc> {
71
75
  build(attrs: InternalTransferAttrs): HydratedDocument<InternalTransferDoc>;
@@ -117,6 +117,16 @@ const buildInternalTransfer = (mongoose) => {
117
117
  type: String,
118
118
  required: true,
119
119
  },
120
+ // Set only by the sweep that reads a deposit's counterparty off the chain.
121
+ // Exchanges do not report who sent an inbound transfer, and some movements
122
+ // can never be attributed - a native transfer leaves no token event, and a
123
+ // chain may have no endpoint configured - so this records how many times
124
+ // the lookup has been tried and when it may be tried again. Without it the
125
+ // sweep would re-attempt the same permanently unresolvable rows forever.
126
+ counterpartyLookup: {
127
+ attempts: { type: Number },
128
+ nextAttemptAt: { type: Date },
129
+ },
120
130
  }, {
121
131
  toJSON: {
122
132
  transform(doc, ret) {
@@ -136,6 +146,14 @@ const buildInternalTransfer = (mongoose) => {
136
146
  "destination.providerId": 1,
137
147
  });
138
148
  InternalTransferSchema.index({ blockchainTxId: 1 });
149
+ // Supports the sweep that fills in missing deposit counterparties. Its steady
150
+ // state is finding nothing, so without an index that narrows on both legs it
151
+ // would scan the collection on every run just to prove there is no work.
152
+ InternalTransferSchema.index({
153
+ "destination.provider": 1,
154
+ "origin.provider": 1,
155
+ "counterpartyLookup.nextAttemptAt": 1,
156
+ });
139
157
  InternalTransferSchema.statics.build = (attrs) => {
140
158
  return new InternalTransfer(attrs);
141
159
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2884",
3
+ "version": "1.0.2886",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",