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

Feature/better sdk 2 #3625

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ The following existing data models were either added, removed, or modified by ha
- For any data model with a `Timestamp`, that data model now also has an (automatically-generated) `Date` field.

### New data models:
- `ChunkPinReport`: Added `ChunkPinReport` data model. Used by the `chifra chunks` command.
- `ChunkPin`: Added `ChunkPin` data model. Used by the `chifra chunks` command.
- `Slurp`: Added `Slurp` data model. Used by the `chifra slurp` command.

### Remove data models
Expand Down
6 changes: 3 additions & 3 deletions docs/content/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,7 @@ paths:
schema:
properties:
data:
description: Produces <a href="/data-model/accounts/#appearance">Appearance</a>, <a href="/data-model/accounts/#appearancetable">AppearanceTable</a>, <a href="/data-model/admin/#chunkaddress">ChunkAddress</a>, <a href="/data-model/admin/#chunkbloom">ChunkBloom</a>, <a href="/data-model/admin/#chunkindex">ChunkIndex</a>, <a href="/data-model/admin/#chunkpinreport">ChunkPinReport</a>, <a href="/data-model/admin/#chunkrecord">ChunkRecord</a>, <a href="/data-model/admin/#chunkstats">ChunkStats</a>, <a href="/data-model/admin/#ipfspin">IpfsPin</a>, <a href="/data-model/admin/#manifest">Manifest</a> or <a href="/data-model/admin/#reportcheck">ReportCheck</a> data. Corresponds to the <a href="/chifra/admin/#chifra-chunks">chifra chunks</a> command line.
description: Produces <a href="/data-model/accounts/#appearance">Appearance</a>, <a href="/data-model/accounts/#appearancetable">AppearanceTable</a>, <a href="/data-model/admin/#chunkaddress">ChunkAddress</a>, <a href="/data-model/admin/#chunkbloom">ChunkBloom</a>, <a href="/data-model/admin/#chunkindex">ChunkIndex</a>, <a href="/data-model/admin/#chunkpin">ChunkPin</a>, <a href="/data-model/admin/#chunkrecord">ChunkRecord</a>, <a href="/data-model/admin/#chunkstats">ChunkStats</a>, <a href="/data-model/admin/#ipfspin">IpfsPin</a>, <a href="/data-model/admin/#manifest">Manifest</a> or <a href="/data-model/admin/#reportcheck">ReportCheck</a> data. Corresponds to the <a href="/chifra/admin/#chifra-chunks">chifra chunks</a> command line.
type: array
items:
oneOf:
Expand All @@ -2700,7 +2700,7 @@ paths:
- $ref: "#/components/schemas/chunkAddress"
- $ref: "#/components/schemas/chunkBloom"
- $ref: "#/components/schemas/chunkIndex"
- $ref: "#/components/schemas/chunkPinReport"
- $ref: "#/components/schemas/chunkPin"
- $ref: "#/components/schemas/chunkRecord"
- $ref: "#/components/schemas/chunkStats"
- $ref: "#/components/schemas/ipfsPin"
Expand Down Expand Up @@ -4398,7 +4398,7 @@ components:
type: string
format: string
description: "the reason for the test"
chunkPinReport:
chunkPin:
description: "a JSON object containing the results of pinning the Unchained Index"
type: object
properties:
Expand Down
2 changes: 1 addition & 1 deletion docs/content/chifra/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Data models produced by this tool:
- [chunkaddress](/data-model/admin/#chunkaddress)
- [chunkbloom](/data-model/admin/#chunkbloom)
- [chunkindex](/data-model/admin/#chunkindex)
- [chunkpinreport](/data-model/admin/#chunkpinreport)
- [chunkpin](/data-model/admin/#chunkpin)
- [chunkrecord](/data-model/admin/#chunkrecord)
- [chunkstats](/data-model/admin/#chunkstats)
- [ipfspin](/data-model/admin/#ipfspin)
Expand Down
6 changes: 3 additions & 3 deletions docs/content/data-model/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ ReportChecks consist of the following fields:
| msgStrings | an array of messages explaining failed checks | string[] |
| reason | the reason for the test | string |

## ChunkPinReport
## ChunkPin

Reports on the result of the command `chifra chunks manifest --pin [--deep]`.

The following commands produce and manage ChunkPinReports:
The following commands produce and manage ChunkPins:

- [chifra chunks](/chifra/admin/#chifra-chunks)

ChunkPinReports consist of the following fields:
ChunkPins consist of the following fields:

| Field | Description | Type |
| ------------- | ------------------------------------------------------- | -------- |
Expand Down
1 change: 0 additions & 1 deletion examples/findFirst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func worker(blknumChan <-chan uint64, wg *sync.WaitGroup, mu *sync.Mutex, minBlo
for blknum := range blknumChan {
opts := sdk.BlocksOptions{
BlockIds: []string{fmt.Sprintf("%d", blknum)},
Count: true,
}

blocks, _, err := opts.BlocksCount()
Expand Down
11 changes: 0 additions & 11 deletions examples/usesSdk/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func DoBlocks() {
}
}

opts.Hashes = true
if blocksHashes, _, err := opts.BlocksHashes(); err != nil {
logger.Error(err)
} else {
Expand All @@ -40,8 +39,6 @@ func DoBlocks() {
}
}

opts.Hashes = false
opts.Traces = true
if blockTraces, _, err := opts.BlocksTraces(); err != nil {
logger.Error(err)
} else {
Expand All @@ -53,8 +50,6 @@ func DoBlocks() {
}
}

opts.Traces = false
opts.Uniq = true
// if blockApps, _, err := opts.BlocksUniq(); err != nil {
// logger.Error(err)
// } else {
Expand All @@ -66,8 +61,6 @@ func DoBlocks() {
// }
// }

opts.Uniq = false
opts.Logs = true
if blocksLogs, _, err := opts.BlocksLogs(); err != nil {
logger.Error(err)
} else {
Expand All @@ -79,8 +72,6 @@ func DoBlocks() {
}
}

opts.Logs = false
opts.Withdrawals = true
if blocksWithdrawals, _, err := opts.BlocksWithdrawals(); err != nil {
logger.Error(err)
} else {
Expand All @@ -92,8 +83,6 @@ func DoBlocks() {
}
}

opts.Withdrawals = false
opts.Count = false
if blocksCounts, _, err := opts.BlocksCount(); err != nil {
logger.Error(err)
} else {
Expand Down
10 changes: 1 addition & 9 deletions examples/usesSdk/chunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ func DoChunks() {
logger.Info("DoChunks")

opts := sdk.ChunksOptions{
Mode: sdk.CMManifest,
FirstBlock: 1000,
LastBlock: 2000,
}

logger.Info("ChunksManifest")
opts.Mode = sdk.CMManifest
if chunksManifest, _, err := opts.ChunksManifest(); err != nil {
logger.Error(err)
} else {
Expand All @@ -26,7 +24,6 @@ func DoChunks() {
}

logger.Info("ChunksIndex")
opts.Mode = sdk.CMIndex
if chunksIndex, _, err := opts.ChunksIndex(); err != nil {
logger.Error(err)
} else {
Expand All @@ -36,7 +33,6 @@ func DoChunks() {
}

logger.Info("ChunksBlooms")
opts.Mode = sdk.CMBlooms
if chunksBlooms, _, err := opts.ChunksBlooms(); err != nil {
logger.Error(err)
} else {
Expand All @@ -47,7 +43,6 @@ func DoChunks() {

logger.Info("ChunksPins")
opts.List = true
opts.Mode = sdk.CMPins
if chunksPins, _, err := opts.ChunksPins(); err != nil {
logger.Error(err)
} else {
Expand All @@ -58,7 +53,6 @@ func DoChunks() {

logger.Info("ChunksAddresses")
opts.List = false
opts.Mode = sdk.CMAddresses
// if chunksAddresses, _, err := opts.ChunksAddresses(); err != nil {
// logger.Error(err)
// } else {
Expand All @@ -68,7 +62,6 @@ func DoChunks() {
// }

logger.Info("ChunksAppearances")
opts.Mode = sdk.CMAppearances
// if chunksAppearances, _, err := opts.ChunksAppearances(); err != nil {
// logger.Error(err)
// } else {
Expand All @@ -81,8 +74,7 @@ func DoChunks() {
// }

logger.Info("ChunksStats")
opts.Mode = sdk.CMStats
if chunkStats, _, err := opts.ChunkStats(); err != nil {
if chunkStats, _, err := opts.ChunksStats(); err != nil {
logger.Error(err)
} else {
if err := SaveToFile("usesSDK/chunkStats.json", chunkStats); err != nil {
Expand Down
23 changes: 9 additions & 14 deletions examples/usesSdk/export.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
package main

import (
"bytes"
"fmt"

"github.com/TrueBlocks/trueblocks-core/sdk"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger"
)

// DoExport tests the When sdk function
func DoExport() {
logger.Info("DoExport")

opts := sdk.ExportOptions{
Addrs: []string{testAddrs[0]},
}
// opts := sdk.ExportOptions{
// Addrs: []string{testAddrs[0]},
// }

buf := bytes.Buffer{}
if err := opts.ExportBytes(&buf); err != nil {
logger.Error(err)
}
// buf := bytes.Buffer{}
// if err := opts.ExportBytes(&buf); err != nil {
// logger.Error(err)
// }

file.StringToAsciiFile("usesSDK/export.json", buf.String())
fmt.Println(buf.String())
// file.StringToAsciiFile("usesSDK/export.json", buf.String())
// fmt.Println(buf.String())
}

// func (opts *ExportOptions) Export() ([]types.Transaction, *types.MetaData, error) {
Expand Down
22 changes: 8 additions & 14 deletions examples/usesSdk/init.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
package main

import (
"bytes"
"fmt"

"github.com/TrueBlocks/trueblocks-core/sdk"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger"
)

// DoInit tests the When sdk function
func DoInit() {
logger.Info("DoInit")

opts := sdk.InitOptions{
All: true,
}
// opts := sdk.InitOptions{
// }

buf := bytes.Buffer{}
if err := opts.InitBytes(&buf); err != nil {
logger.Error(err)
}
// buf := bytes.Buffer{}
// if err := opts.InitBytes(&buf); err != nil {
// logger.Error(err)
// }

file.StringToAsciiFile("usesSDK/init.json", buf.String())
fmt.Println(buf.String())
// file.StringToAsciiFile("usesSDK/init.json", buf.String())
// fmt.Println(buf.String())
}

// func (opts *InitOptions) InitAll() ([]bool, *types.MetaData, error) {
1 change: 0 additions & 1 deletion examples/usesSdk/monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ func DoMonitors() {

opts := sdk.MonitorsOptions{
Addrs: []string{testAddrs[0]},
List: true,
}

if monitors, _, err := opts.MonitorsList(); err != nil {
Expand Down
3 changes: 0 additions & 3 deletions examples/usesSdk/slurp.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func DoSlurp() {
}
}

opts.Appearances = true
if appearances, _, err := opts.SlurpAppearances(); err != nil {
logger.Error(err)
} else {
Expand All @@ -38,8 +37,6 @@ func DoSlurp() {
}
}

opts.Appearances = true
opts.Count = true
if counts, _, err := opts.SlurpCount(); err != nil {
logger.Error(err)
} else {
Expand Down
6 changes: 3 additions & 3 deletions examples/usesSdk/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func DoState() {
}

opts.Articulate = true
opts.Call = "manifestHashMap(0x02f2b09b33fdbd406ead954a31f98bd29a2a3492,\"mainnet\")"
if stateResult, _, err := opts.StateCall(); err != nil {
call := "manifestHashMap(0x02f2b09b33fdbd406ead954a31f98bd29a2a3492,\"mainnet\")"
if stateResult, _, err := opts.StateCall(call); err != nil {
logger.Error(err)
} else {
if err := SaveAndClean[types.Result]("usesSDK/stateResult.json", stateResult, &opts, func() error {
_, _, err := opts.StateCall()
_, _, err := opts.StateCall(call)
return err
}); err != nil {
logger.Error(err)
Expand Down
5 changes: 0 additions & 5 deletions examples/usesSdk/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func DoTransactions() {
}
}

opts.Traces = true
if transactionsTraces, _, err := opts.TransactionsTraces(); err != nil {
logger.Error(err)
} else {
Expand All @@ -37,8 +36,6 @@ func DoTransactions() {
}
}

opts.Traces = false
opts.Uniq = true
if transactionsUniq, _, err := opts.TransactionsUniq(); err != nil {
logger.Error(err)
} else {
Expand All @@ -50,8 +47,6 @@ func DoTransactions() {
}
}

opts.Uniq = false
opts.Logs = true
opts.Articulate = true
if transactionsLogs, _, err := opts.TransactionsLogs(); err != nil {
logger.Error(err)
Expand Down
3 changes: 0 additions & 3 deletions examples/usesSdk/when.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func DoWhen() {
}
}

opts.Timestamps = true
if whenTimestamps, _, err := opts.WhenTimestamps(); err != nil {
logger.Error(err)
} else {
Expand All @@ -38,8 +37,6 @@ func DoWhen() {
}
}

// opts.Timestamps = false
opts.Count = true
if whenCount, _, err := opts.WhenCount(); err != nil {
logger.Error(err)
} else {
Expand Down
Loading
Loading