Skip to content

Commit 5c803a7

Browse files
committed
docs: add contested index info
1 parent cc911a1 commit 5c803a7

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

docs/reference/data-contracts.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,10 @@ The `indices` array consists of:
226226
* A `properties` array composed of a `<field name: sort order>` object for each document field that is part of the index (sort order: [`asc` only](https://github.com/dashpay/platform/pull/435) for Dash Platform v0.23)
227227
* An (optional) `unique` element that determines if duplicate values are allowed for the document
228228

229-
> 🚧 Compound Indices
230-
>
231-
> When defining an index with multiple properties (i.e a compound index), the order in which the properties are listed is important. Refer to the [mongoDB documentation](https://docs.mongodb.com/manual/core/index-compound/#prefixes) for details regarding the significance of the order as it relates to querying capabilities. Dash uses [GroveDB](https://github.com/dashpay/grovedb), which works similarly but does require listing all the index's fields in query order by statements.
229+
:::{admonition} Compound Indices
230+
:class: attention
231+
When defining an index with multiple properties (i.e a compound index), the order in which the properties are listed is important. Refer to the [mongoDB documentation](https://docs.mongodb.com/manual/core/index-compound/#prefixes) for details regarding the significance of the order as it relates to querying capabilities. Dash uses [GroveDB](https://github.com/dashpay/grovedb), which works similarly but does require listing all the index's fields in query order by statements.
232+
:::
232233

233234
```json
234235
"indices": [
@@ -247,6 +248,38 @@ The `indices` array consists of:
247248
]
248249
```
249250

251+
#### Contested indices
252+
253+
Contested unique indices provide a way for multiple identities to compete for ownership when a new document field matches a predefined pattern. This system enables fair distribution of valuable documents through community-driven decision-making.
254+
255+
A two week contest begins when a match occurs. For the first week, additional contenders can join by paying a fee of 0.2 Dash. During this period, masternodes and evonodes vote on the outcome. The contest can result in the awarding of the document to the winner, a locked vote where no document is awarded, or potentially a restart of the contest if specific conditions are met.
256+
257+
The table below describes the properties used to configure a contested index:
258+
259+
| Property Name | Type | Description |
260+
|-|-|-|
261+
| fieldMatches | array | Array containing conditions to check |
262+
| fieldMatches.field | string | Name of the field to check for matches |
263+
| fieldMatches.regexPattern | string | Regex used to check for matches |
264+
| resolution | integer | Method to resolve the contest:<br>`0` - masternode voting |
265+
266+
**Example**
267+
268+
This example (from the [DPNS contract's `domain` document](https://github.com/dashpay/platform/blob/master/packages/dpns-contract/schema/v1/dpns-contract-documents.json)) demonstrates the use of a contested index:
269+
270+
``` json
271+
"contested": {
272+
"fieldMatches": [
273+
{
274+
"field": "normalizedLabel",
275+
"regexPattern": "^[a-zA-Z01-]{3,19}$"
276+
}
277+
],
278+
"resolution": 0,
279+
"description": "If the normalized label part of this index is less than 20 characters (all alphabet a-z, A-Z, 0, 1, and -) then a masternode vote contest takes place to give out the name"
280+
}
281+
```
282+
250283
#### Index Constraints
251284

252285
For performance and security reasons, indices have the following constraints. These constraints are subject to change over time.

0 commit comments

Comments
 (0)