Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude sat range end from calculating block based rarities #13

Conversation

haozhiliu
Copy link

@haozhiliu haozhiliu commented Aug 20, 2023

Found the unspent range's end index should be excluded from the sat range.
And return the block rarity chunks within sat ranges, instead of total count.

Below is an example:
POST: /rpc/v1 with payload

{
"jsonrpc": "2.0",
"method": "getSatRanges",
"params": { "utxos": ["6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"]},
"id": 0
}

The expected response after fix is:

{
    "jsonrpc": "2.0",
    "result": {
        "rare_sats": [
            {
                "offset": 0,
                "rarity": "uncommon",
                "sat": 2745000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "549.0",
                    "degree": "0°549′549″0‴",
                    "epoch": 0,
                    "height": 549,
                    "name": "nvfzolywpwr",
                    "number": 2745000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 5000000000,
                "rarity": "uncommon",
                "sat": 385000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "77.0",
                    "degree": "0°77′77″0‴",
                    "epoch": 0,
                    "height": 77,
                    "name": "nvrhkcdwqfx",
                    "number": 385000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 10000000000,
                "rarity": "uncommon",
                "sat": 3270000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "654.0",
                    "degree": "0°654′654″0‴",
                    "epoch": 0,
                    "height": 654,
                    "name": "nvdmezeayyj",
                    "number": 3270000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 15000000000,
                "rarity": "uncommon",
                "sat": 8715000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "1743.0",
                    "degree": "0°1743′1743″0‴",
                    "epoch": 0,
                    "height": 1743,
                    "name": "nudkguxlxdh",
                    "number": 8715000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 20000000000,
                "rarity": "uncommon",
                "sat": 10510000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "2102.0",
                    "degree": "0°2102′86″0‴",
                    "epoch": 0,
                    "height": 2102,
                    "name": "ntuuuedgfiv",
                    "number": 10510000000000,
                    "offset": 0,
                    "period": 1,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 25000000000,
                "rarity": "uncommon",
                "sat": 7755000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "1551.0",
                    "degree": "0°1551′1551″0‴",
                    "epoch": 0,
                    "height": 1551,
                    "name": "nuhzulqgeij",
                    "number": 7755000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 30000000000,
                "rarity": "uncommon",
                "sat": 8580000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "1716.0",
                    "degree": "0°1716′1716″0‴",
                    "epoch": 0,
                    "height": 1716,
                    "name": "nuebbvfuldp",
                    "number": 8580000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 35000000000,
                "rarity": "uncommon",
                "sat": 3495000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "699.0",
                    "degree": "0°699′699″0‴",
                    "epoch": 0,
                    "height": 699,
                    "name": "nvckepyvkgn",
                    "number": 3495000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 40000000000,
                "rarity": "uncommon",
                "sat": 515000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "103.0",
                    "degree": "0°103′103″0‴",
                    "epoch": 0,
                    "height": 103,
                    "name": "nvqrfgraxxx",
                    "number": 515000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "offset": 45000000000,
                "rarity": "uncommon",
                "sat": 5950000000000,
                "sat_details": {
                    "cycle": 0,
                    "decimal": "1190.0",
                    "degree": "0°1190′1190″0‴",
                    "epoch": 0,
                    "height": 1190,
                    "name": "nuqqnmblnnl",
                    "number": 5950000000000,
                    "offset": 0,
                    "period": 0,
                    "rarity": "uncommon"
                },
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            }
        ],
        "sat_ranges": [
            {
                "block_rarities": [
                    {
                        "block_rarity": "vintage",
                        "chunks": [
                            [
                                2745000000000,
                                2750000000000
                            ]
                        ]
                    }
                ],
                "end": 2750000000000,
                "start": 2745000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [
                    {
                        "block_rarity": "vintage",
                        "chunks": [
                            [
                                385000000000,
                                390000000000
                            ]
                        ]
                    }
                ],
                "end": 390000000000,
                "start": 385000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [
                    {
                        "block_rarity": "vintage",
                        "chunks": [
                            [
                                3270000000000,
                                3275000000000
                            ]
                        ]
                    }
                ],
                "end": 3275000000000,
                "start": 3270000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [],
                "end": 8720000000000,
                "start": 8715000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [],
                "end": 10515000000000,
                "start": 10510000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [],
                "end": 7760000000000,
                "start": 7755000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [],
                "end": 8585000000000,
                "start": 8580000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [
                    {
                        "block_rarity": "vintage",
                        "chunks": [
                            [
                                3495000000000,
                                3500000000000
                            ]
                        ]
                    }
                ],
                "end": 3500000000000,
                "start": 3495000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [
                    {
                        "block_rarity": "vintage",
                        "chunks": [
                            [
                                515000000000,
                                520000000000
                            ]
                        ]
                    }
                ],
                "end": 520000000000,
                "start": 515000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            },
            {
                "block_rarities": [],
                "end": 5954999999859,
                "start": 5950000000000,
                "utxo": "6eb09a05147c13f442950028b701e53bf5981feb44e07bc89b0d7b3d4eb9801a:1"
            }
        ]
    },
    "id": 0
}

@haozhiliu haozhiliu merged commit c7e0ac5 into 6.x Aug 23, 2023
4 of 6 checks passed
nothing0012 pushed a commit that referenced this pull request Sep 11, 2023
* exclude sat range end from calculating block based rarities

* fix cargo ci

* change rpc to return block rarity chunks instead of total count

* improve block rarity response format to support new rarities in the future
nothing0012 pushed a commit that referenced this pull request Sep 26, 2023
* exclude sat range end from calculating block based rarities

* fix cargo ci

* change rpc to return block rarity chunks instead of total count

* improve block rarity response format to support new rarities in the future
nothing0012 pushed a commit that referenced this pull request Oct 23, 2023
* exclude sat range end from calculating block based rarities

* fix cargo ci

* change rpc to return block rarity chunks instead of total count

* improve block rarity response format to support new rarities in the future
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants