From 3825a6eb9db13235bddffb4bb0fc2b8e3b822716 Mon Sep 17 00:00:00 2001 From: Laysa Bitencourt Date: Mon, 24 Jun 2024 18:12:02 -0300 Subject: [PATCH] [412 and 408 HUBBLE ] - Automated linting (#257) * show current errors * show linting errors * new config * CI ready * CI final * UpdateOrderbook unchanged --- .github/pull_request_template.md | 18 ++-- .github/release-drafter.yml | 10 +-- .github/workflows/codeql.yml | 36 ++++---- .github/workflows/internal.yml | 39 ++++----- .github/workflows/lint-tests.yml | 32 +++++++ .github/workflows/release.yml | 136 ++++++++++++++--------------- .gitignore | 1 + .golangci.yml | 11 +++ .pre-commit-config.yaml | 25 ++++++ README.md | 11 +-- cmd/export_ledger_entry_changes.go | 6 +- cmd/export_ledgers_test.go | 4 +- cmd/get_ledger_range_from_times.go | 2 +- internal/input/orderbooks.go | 4 +- internal/input/trades.go | 2 +- internal/toid/main.go | 33 ++++--- internal/toid/main_test.go | 6 +- internal/toid/synt_offer_id.go | 5 +- 18 files changed, 223 insertions(+), 158 deletions(-) create mode 100644 .github/workflows/lint-tests.yml create mode 100644 .golangci.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 09a19adf..34a4b107 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,23 +4,23 @@ change is, and why it is being made, with enough context for anyone to understan
PR Checklist - + ### PR Structure -* [ ] This PR has reasonably narrow scope (if not, break it down into smaller PRs). -* [ ] This PR avoids mixing refactoring changes with feature changes (split into two PRs - otherwise). -* [ ] This PR's title starts with the jira ticket associated with the PR. +- [ ] This PR has reasonably narrow scope (if not, break it down into smaller PRs). +- [ ] This PR avoids mixing refactoring changes with feature changes (split into two PRs + otherwise). +- [ ] This PR's title starts with the jira ticket associated with the PR. ### Thoroughness -* [ ] This PR adds tests for the most critical parts of the new functionality or fixes. -* [ ] I've updated the README with the added features, breaking changes, new instructions on how to use the repository. I updated the description of the fuction with the changes that were made. +- [ ] This PR adds tests for the most critical parts of the new functionality or fixes. +- [ ] I've updated the README with the added features, breaking changes, new instructions on how to use the repository. I updated the description of the fuction with the changes that were made. ### Release planning -* [ ] I've decided if this PR requires a new major/minor/patch version accordingly to - [semver](https://semver.org/), and I've changed the name of the BRANCH to release/* , feature/* or patch/* . +- [ ] I've decided if this PR requires a new major/minor/patch version accordingly to + [semver](https://semver.org/), and I've changed the name of the BRANCH to release/_ , feature/_ or patch/\* .
### What diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index f627cd0e..b4505e02 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,5 +1,5 @@ -template: | - ## What's Changed - $CHANGES - - **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION \ No newline at end of file +template: | + ## What's Changed + $CHANGES + + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5907fe11..92bc0800 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,11 +2,11 @@ name: "CodeQL" on: push: - branches: [ "master" ] + branches: ["master"] pull_request: - branches: [ "master" ] + branches: ["master"] schedule: - - cron: '42 15 * * 6' + - cron: "42 15 * * 6" jobs: analyze: @@ -21,21 +21,21 @@ jobs: fail-fast: false matrix: include: - - language: go - build-mode: autobuild - + - language: go + build-mode: autobuild + steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/internal.yml b/.github/workflows/internal.yml index 99fda785..54c55d14 100644 --- a/.github/workflows/internal.yml +++ b/.github/workflows/internal.yml @@ -2,32 +2,31 @@ name: internal on: pull_request: - branches: [ master ] + branches: [master] jobs: - build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1 - - name: Build Internal - working-directory: internal - run: go build ./... + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1 + - name: Build Internal + working-directory: internal + run: go build ./... unit-tests: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1 - - name: Run Internal Unit Tests - working-directory: internal - run: go test -v -cover ./... + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1 + - name: Run Internal Unit Tests + working-directory: internal + run: go test -v -cover ./... diff --git a/.github/workflows/lint-tests.yml b/.github/workflows/lint-tests.yml new file mode 100644 index 00000000..d0ae9c44 --- /dev/null +++ b/.github/workflows/lint-tests.yml @@ -0,0 +1,32 @@ +name: Linting + +on: + pull_request: + branches: + - master + +jobs: + pre-commit: + runs-on: ubuntu-latest + if: >- + github.event.pull_request.merged == false && + github.event.pull_request.state == 'open' + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all history + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1 + + - id: file_changes + uses: trilom/file-changes-action@v1.2.3 + with: + output: " " + + - uses: pre-commit/action@v3.0.0 + env: + extra_args: --color=always --files ${{ steps.file_changes.outputs.files}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f10d8fb5..155d5986 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,68 +1,68 @@ -name: Release Drafter and Publisher - -on: - pull_request: - types: [closed] - -permissions: - contents: read - -jobs: - new_release: - if: github.event.pull_request.merged == true - permissions: - # write permission is required to create a github release - contents: write - # write permission is required for autolabeler - # otherwise, read permission is required at least - pull-requests: write - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Get branch name - id: getbranch - run: echo ::set-output name=BRANCH::${GITHUB_HEAD_REF} - - # ${{ github.ref }} was not giving v* as tag name, but refs/tags/v* instead, so It had to be abbreviated - - name: Get latest abbreviated tag - id: gettag - run: echo ::set-output name=TAG::$(git describe --tags $(git rev-list --tags --max-count=1)) # get the latest tag across all branches and put it in the output TAG - - - name: Calculate next version - id: nextversion - run: | - BRANCH_NAME="${{ steps.getbranch.outputs.BRANCH }}" - CURRENT_VERSION="${{ steps.gettag.outputs.TAG }}" - CURRENT_VERSION="${CURRENT_VERSION#v}" # Remove the 'v' from the start of the version - IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" - if [[ $BRANCH_NAME =~ ^release/ ]]; then - VERSION_PARTS[0]=$((VERSION_PARTS[0] + 1)) - VERSION_PARTS[1]=0 - VERSION_PARTS[2]=0 - elif [[ $BRANCH_NAME =~ ^feature/ ]]; then - VERSION_PARTS[1]=$((VERSION_PARTS[1] + 1)) - VERSION_PARTS[2]=0 - elif [[ $BRANCH_NAME =~ ^patch/ ]]; then - VERSION_PARTS[2]=$((VERSION_PARTS[2] + 1)) - fi - NEXT_VERSION="v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" - echo ::set-output name=NEXT_VERSION::"$NEXT_VERSION" - - - name: Create and publish new tag - run: | - git tag ${{ steps.nextversion.outputs.NEXT_VERSION }} - git push origin ${{ steps.nextversion.outputs.NEXT_VERSION }} - - - uses: release-drafter/release-drafter@v5 - with: - commitish: master - name: "stellar-etl ${{ steps.nextversion.outputs.NEXT_VERSION }}" - tag: ${{ steps.nextversion.outputs.NEXT_VERSION }} - publish: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +name: Release Drafter and Publisher + +on: + pull_request: + types: [closed] + +permissions: + contents: read + +jobs: + new_release: + if: github.event.pull_request.merged == true + permissions: + # write permission is required to create a github release + contents: write + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: write + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get branch name + id: getbranch + run: echo ::set-output name=BRANCH::${GITHUB_HEAD_REF} + + # ${{ github.ref }} was not giving v* as tag name, but refs/tags/v* instead, so It had to be abbreviated + - name: Get latest abbreviated tag + id: gettag + run: echo ::set-output name=TAG::$(git describe --tags $(git rev-list --tags --max-count=1)) # get the latest tag across all branches and put it in the output TAG + + - name: Calculate next version + id: nextversion + run: | + BRANCH_NAME="${{ steps.getbranch.outputs.BRANCH }}" + CURRENT_VERSION="${{ steps.gettag.outputs.TAG }}" + CURRENT_VERSION="${CURRENT_VERSION#v}" # Remove the 'v' from the start of the version + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + if [[ $BRANCH_NAME =~ ^release/ ]]; then + VERSION_PARTS[0]=$((VERSION_PARTS[0] + 1)) + VERSION_PARTS[1]=0 + VERSION_PARTS[2]=0 + elif [[ $BRANCH_NAME =~ ^feature/ ]]; then + VERSION_PARTS[1]=$((VERSION_PARTS[1] + 1)) + VERSION_PARTS[2]=0 + elif [[ $BRANCH_NAME =~ ^patch/ ]]; then + VERSION_PARTS[2]=$((VERSION_PARTS[2] + 1)) + fi + NEXT_VERSION="v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" + echo ::set-output name=NEXT_VERSION::"$NEXT_VERSION" + + - name: Create and publish new tag + run: | + git tag ${{ steps.nextversion.outputs.NEXT_VERSION }} + git push origin ${{ steps.nextversion.outputs.NEXT_VERSION }} + + - uses: release-drafter/release-drafter@v5 + with: + commitish: master + name: "stellar-etl ${{ steps.nextversion.outputs.NEXT_VERSION }}" + tag: ${{ steps.nextversion.outputs.NEXT_VERSION }} + publish: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index a450b63a..a3b18857 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ debug *.csr *.key stellar-etl +env ### Credentials checks credentials.json diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..0e7b5035 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,11 @@ +linters: + disable: + - gosimple + - errcheck + - ineffassign + - staticcheck + + enable: + - goimports # Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode. + - importas # Enforces consistent import aliases. + - misspell # Finds commonly misspelled English words. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..5152a6b9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-added-large-files # prevents giant files from being committed. + - id: check-case-conflict # checks for files that would conflict in case-insensitive filesystems. + - id: check-merge-conflict # checks for files that contain merge conflict strings. + - id: detect-private-key # detects the presence of private keys. + - id: end-of-file-fixer # ensures that a file is either empty, or ends with one newline. + - id: fix-byte-order-marker # removes utf-8 byte order marker. + - id: mixed-line-ending # replaces or checks mixed line ending. + - id: trailing-whitespace # trims trailing whitespace. + + - repo: https://github.com/golangci/golangci-lint + rev: v1.59.1 + hooks: + - id: golangci-lint + entry: golangci-lint run --fix + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + files: \.(json|markdown|md|yaml|yml)$ + language_version: 14.21.3 diff --git a/README.md b/README.md index 97cf6318..ab21a96b 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ The Stellar-ETL is a data pipeline that allows users to extract data from the hi Pay attention, it is very important to know if your modification to this repository is a release (breaking changes), a feature (functionalities) or a patch(to fix bugs). With that information, create your branch name like this: -* ```release/``` -* ```feature/``` -* ```patch/``` +- `release/` +- `feature/` +- `patch/` -If branch is already made, just rename it *before passing the pull request*. +If branch is already made, just rename it _before passing the pull request_. ## **Table of Contents** @@ -120,7 +120,8 @@ These commands export information using the [Ledger Exporter](https://github.com > _*NOTE:*_ Using captive-core requires a Stellar Core instance that is v20.0.0 or later. The commands use the Core instance to retrieve information about changes from the ledger. More information about the Stellar ledger information can be found [here](https://developers.stellar.org/network/horizon/api-reference/resources). >
As the Stellar network grows, the Stellar Core instance has to catch up on an increasingly large amount of information. This catch-up process can add some overhead to the commands in this category. In order to avoid this overhead, run prefer processing larger ranges instead of many small ones, or use unbounded mode. ->

Recommended resources for running captive-core within a KubernetesPod: +>

Recommended resources for running captive-core within a KubernetesPod: +> > ``` > {cpu: 3.5, memory: 20Gi, ephemeral-storage: 12Gi} > ``` diff --git a/cmd/export_ledger_entry_changes.go b/cmd/export_ledger_entry_changes.go index b227defe..dfb4ae75 100644 --- a/cmd/export_ledger_entry_changes.go +++ b/cmd/export_ledger_entry_changes.go @@ -19,11 +19,11 @@ var exportLedgerEntryChangesCmd = &cobra.Command{ Use: "export_ledger_entry_changes", Short: "This command exports the changes in accounts, offers, trustlines and liquidity pools.", Long: `This command instantiates a stellar-core instance and uses it to export about accounts, offers, trustlines and liquidity pools. -The information is exported in batches determined by the batch-size flag. Each exported file will include the changes to the +The information is exported in batches determined by the batch-size flag. Each exported file will include the changes to the relevant data type that occurred during that batch. -If the end-ledger is omitted, then the stellar-core node will continue running and exporting information as new ledgers are -confirmed by the Stellar network. +If the end-ledger is omitted, then the stellar-core node will continue running and exporting information as new ledgers are +confirmed by the Stellar network. If no data type flags are set, then by default all of them are exported. If any are set, it is assumed that the others should not be exported.`, diff --git a/cmd/export_ledgers_test.go b/cmd/export_ledgers_test.go index 8006ea6d..9a1e1f63 100644 --- a/cmd/export_ledgers_test.go +++ b/cmd/export_ledgers_test.go @@ -4,7 +4,7 @@ import ( "bytes" "flag" "fmt" - "io/ioutil" + "io" "log" "os" "os/exec" @@ -229,7 +229,7 @@ func getGolden(t *testing.T, goldenFile string, actual string, update bool) (str return actual, nil } - wantOutput, err := ioutil.ReadAll(f) + wantOutput, err := io.ReadAll(f) if err != nil { return "", err } diff --git a/cmd/get_ledger_range_from_times.go b/cmd/get_ledger_range_from_times.go index 3edfff35..07cc5041 100644 --- a/cmd/get_ledger_range_from_times.go +++ b/cmd/get_ledger_range_from_times.go @@ -44,7 +44,7 @@ var getLedgerRangeFromTimesCmd = &cobra.Command{ cmdLogger.Fatal("could not get testnet boolean: ", err) } - isFuture, err := cmd.Flags().GetBool("futurenet") + isFuture, err := cmd.Flags().GetBool("futurenet") if err != nil { cmdLogger.Fatal("could not get futurenet boolean: ", err) } diff --git a/internal/input/orderbooks.go b/internal/input/orderbooks.go index 96ce8ca7..95c1f2bc 100644 --- a/internal/input/orderbooks.go +++ b/internal/input/orderbooks.go @@ -59,7 +59,6 @@ func NewOrderbookParser(logger *utils.EtlLogger) OrderbookParser { } } - func (o *OrderbookParser) parseOrderbook(orderbook []ingest.Change, seq uint32) { var group sync.WaitGroup allConverted := make([]transform.NormalizedOfferOutput, len(orderbook)) @@ -119,7 +118,7 @@ func (o *OrderbookParser) parseOrderbook(orderbook []ingest.Change, seq uint32) } } -// GetOfferChanges gets the offer changes that ocurred between the firstSeq ledger and nextSeq ledger +// GetOfferChanges gets the offer changes that occurred between the firstSeq ledger and nextSeq ledger func GetOfferChanges(core *ledgerbackend.CaptiveStellarCore, env utils.EnvironmentDetails, firstSeq, nextSeq uint32) (*ingest.ChangeCompactor, error) { offChanges := ingest.NewChangeCompactor() ctx := context.Background() @@ -206,7 +205,6 @@ func UpdateOrderbook(start, end uint32, orderbook []ingest.Change, core *ledgerb for _, change := range orderbook { changeCache.AddChange(change) } - orderbook = changeCache.GetChanges() } diff --git a/internal/input/trades.go b/internal/input/trades.go index 9c26cdf4..afdede71 100644 --- a/internal/input/trades.go +++ b/internal/input/trades.go @@ -45,7 +45,7 @@ func GetTrades(start, end uint32, limit int64, env utils.EnvironmentDetails, use return []TradeTransformInput{}, err } - closeTime, err := utils.TimePointToUTCTimeStamp(txReader.GetHeader().Header.ScpValue.CloseTime) + closeTime, _ := utils.TimePointToUTCTimeStamp(txReader.GetHeader().Header.ScpValue.CloseTime) for int64(len(tradeSlice)) < limit || limit < 0 { tx, err := txReader.Read() diff --git a/internal/toid/main.go b/internal/toid/main.go index 9ce468f5..e91f73c7 100644 --- a/internal/toid/main.go +++ b/internal/toid/main.go @@ -5,7 +5,6 @@ import ( "fmt" ) -// // ID represents the total order of Ledgers, Transactions and // Operations. // @@ -19,36 +18,35 @@ import ( // // The follow diagram shows this format: // -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Ledger Sequence Number | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Transaction Application Order | Op Index | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Ledger Sequence Number | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Transaction Application Order | Op Index | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // // By component: // // Ledger Sequence: 32-bits // -// A complete ledger sequence number in which the operation was validated. +// A complete ledger sequence number in which the operation was validated. // -// Expressed in network byte order. +// Expressed in network byte order. // // Transaction Application Order: 20-bits // -// The order that the transaction was applied within the ledger it was -// validated. Accommodates up to 1,048,575 transactions in a single ledger. +// The order that the transaction was applied within the ledger it was +// validated. Accommodates up to 1,048,575 transactions in a single ledger. // -// Expressed in network byte order. +// Expressed in network byte order. // // Operation Index: 12-bits // -// The index of the operation within its parent transaction. Accommodates up -// to 4095 operations per transaction. -// -// Expressed in network byte order. +// The index of the operation within its parent transaction. Accommodates up +// to 4095 operations per transaction. // +// Expressed in network byte order. // // Note: API Clients should not be interpreting this value. We will use it // as an opaque paging token that clients can parrot back to us after having read @@ -59,7 +57,6 @@ import ( // transaction as well. Given that this ID is only meant for ordering within a // single type of object, the sharing of ids across object types seems // acceptable. -// type ID struct { LedgerSequence int32 TransactionOrder int32 diff --git a/internal/toid/main_test.go b/internal/toid/main_test.go index 70433b1a..cac6305b 100644 --- a/internal/toid/main_test.go +++ b/internal/toid/main_test.go @@ -18,7 +18,7 @@ func TestID_ToInt64(t *testing.T) { expected int64 shouldPanic bool }{ - // accomodates 12-bits of precision for the operation field + // accommodates 12-bits of precision for the operation field { id: &ID{0, 0, 1}, expected: 1, @@ -31,7 +31,7 @@ func TestID_ToInt64(t *testing.T) { id: &ID{0, 0, 4096}, shouldPanic: true, }, - // accomodates 20-bits of precision for the transaction field + // accommodates 20-bits of precision for the transaction field { id: &ID{0, 1, 0}, expected: 4096, @@ -44,7 +44,7 @@ func TestID_ToInt64(t *testing.T) { id: &ID{0, 1048576, 0}, shouldPanic: true, }, - // accomodates 32-bits of precision for the ledger field + // accommodates 32-bits of precision for the ledger field { id: &ID{1, 0, 0}, expected: 4294967296, diff --git a/internal/toid/synt_offer_id.go b/internal/toid/synt_offer_id.go index b0fe4e1b..39777109 100644 --- a/internal/toid/synt_offer_id.go +++ b/internal/toid/synt_offer_id.go @@ -22,8 +22,9 @@ const ( // Due to the 2nd bit being used, the largest possible toid is: // 0011111111111111111111111111111100000000000000000001000000000001 // \ ledger /\ transaction /\ op / -// = 1073741823 -// with avg. 5 sec close time will reach in ~170 years +// +// = 1073741823 +// with avg. 5 sec close time will reach in ~170 years func EncodeOfferId(id uint64, typ OfferIDType) int64 { // First ensure the bits we're going to change are 0s if id&mask != 0 {