@blinklabs/dingo 0.7.0 → 0.8.0
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.
- package/.dingo/blob/000001.sst +0 -0
- package/.dingo/blob/000001.vlog +0 -0
- package/.dingo/blob/DISCARD +0 -0
- package/.dingo/blob/KEYREGISTRY +2 -0
- package/.dingo/blob/MANIFEST +0 -0
- package/.dingo/metadata.sqlite +0 -0
- package/.github/workflows/golangci-lint.yml +1 -1
- package/.github/workflows/publish.yml +1 -7
- package/README.md +2 -1
- package/{bin/dingo → dingo} +0 -0
- package/dingo.yaml.example +53 -0
- package/package.json +2 -2
- package/Dockerfile +0 -25
- package/Makefile +0 -53
- package/blockfetch.go +0 -144
- package/chain/chain.go +0 -504
- package/chain/chain_test.go +0 -468
- package/chain/errors.go +0 -80
- package/chain/event.go +0 -33
- package/chain/iter.go +0 -64
- package/chainsync/chainsync.go +0 -97
- package/chainsync.go +0 -223
- package/cmd/dingo/load.go +0 -52
- package/cmd/dingo/main.go +0 -118
- package/cmd/dingo/serve.go +0 -49
- package/config/cardano/node.go +0 -192
- package/config/cardano/node_test.go +0 -85
- package/config/cardano/preview/README.md +0 -4
- package/config/cardano/preview/alonzo-genesis.json +0 -196
- package/config/cardano/preview/byron-genesis.json +0 -117
- package/config/cardano/preview/config.json +0 -114
- package/config/cardano/preview/conway-genesis.json +0 -297
- package/config/cardano/preview/shelley-genesis.json +0 -68
- package/config.go +0 -245
- package/connmanager/connection_manager.go +0 -105
- package/connmanager/connection_manager_test.go +0 -185
- package/connmanager/event.go +0 -37
- package/connmanager/listener.go +0 -140
- package/connmanager/outbound.go +0 -93
- package/connmanager/socket.go +0 -55
- package/connmanager/unix.go +0 -78
- package/custom-p2p-topology.json +0 -24
- package/custom-p2p-topology.json.backup +0 -24
- package/custom-p2p-topology.json.mainnet +0 -37
- package/database/account.go +0 -180
- package/database/block.go +0 -362
- package/database/certs.go +0 -53
- package/database/commit_timestamp.go +0 -77
- package/database/database.go +0 -118
- package/database/database_test.go +0 -62
- package/database/drep.go +0 -47
- package/database/epoch.go +0 -121
- package/database/immutable/chunk.go +0 -182
- package/database/immutable/immutable.go +0 -350
- package/database/immutable/immutable_test.go +0 -59
- package/database/immutable/primary.go +0 -106
- package/database/immutable/secondary.go +0 -103
- package/database/immutable/testdata/08893.chunk +0 -0
- package/database/immutable/testdata/08893.primary +0 -0
- package/database/immutable/testdata/08893.secondary +0 -0
- package/database/immutable/testdata/08894.chunk +0 -0
- package/database/immutable/testdata/08894.primary +0 -0
- package/database/immutable/testdata/08894.secondary +0 -0
- package/database/immutable/testdata/README.md +0 -4
- package/database/plugin/blob/badger/commit_timestamp.go +0 -50
- package/database/plugin/blob/badger/database.go +0 -152
- package/database/plugin/blob/badger/logger.go +0 -63
- package/database/plugin/blob/badger/metrics.go +0 -98
- package/database/plugin/blob/blob.go +0 -19
- package/database/plugin/blob/store.go +0 -40
- package/database/plugin/log.go +0 -27
- package/database/plugin/metadata/metadata.go +0 -19
- package/database/plugin/metadata/sqlite/account.go +0 -313
- package/database/plugin/metadata/sqlite/certs.go +0 -58
- package/database/plugin/metadata/sqlite/commit_timestamp.go +0 -68
- package/database/plugin/metadata/sqlite/database.go +0 -218
- package/database/plugin/metadata/sqlite/drep.go +0 -140
- package/database/plugin/metadata/sqlite/epoch.go +0 -120
- package/database/plugin/metadata/sqlite/models/account.go +0 -118
- package/database/plugin/metadata/sqlite/models/auth_committee_hot.go +0 -26
- package/database/plugin/metadata/sqlite/models/drep.go +0 -52
- package/database/plugin/metadata/sqlite/models/epoch.go +0 -31
- package/database/plugin/metadata/sqlite/models/models.go +0 -46
- package/database/plugin/metadata/sqlite/models/pool.go +0 -97
- package/database/plugin/metadata/sqlite/models/pparam_update.go +0 -27
- package/database/plugin/metadata/sqlite/models/pparams.go +0 -27
- package/database/plugin/metadata/sqlite/models/resign_committee_cold.go +0 -27
- package/database/plugin/metadata/sqlite/models/stake_vote_delegation.go +0 -27
- package/database/plugin/metadata/sqlite/models/tip.go +0 -26
- package/database/plugin/metadata/sqlite/models/update_drep.go +0 -27
- package/database/plugin/metadata/sqlite/models/utxo.go +0 -30
- package/database/plugin/metadata/sqlite/models/vote_delegation.go +0 -26
- package/database/plugin/metadata/sqlite/models/vote_registration_delegation.go +0 -15
- package/database/plugin/metadata/sqlite/pool.go +0 -240
- package/database/plugin/metadata/sqlite/pparams.go +0 -110
- package/database/plugin/metadata/sqlite/tip.go +0 -83
- package/database/plugin/metadata/sqlite/utxo.go +0 -292
- package/database/plugin/metadata/store.go +0 -198
- package/database/plugin/option.go +0 -190
- package/database/plugin/plugin.go +0 -20
- package/database/plugin/register.go +0 -118
- package/database/pparams.go +0 -145
- package/database/tip.go +0 -45
- package/database/txn.go +0 -147
- package/database/types/types.go +0 -74
- package/database/types/types_test.go +0 -83
- package/database/utxo.go +0 -263
- package/dist/artifacts.json +0 -1
- package/dist/checksums.txt +0 -22
- package/dist/config.yaml +0 -253
- package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz +0 -0
- package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_arm64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_arm64.tar.gz.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_x86_64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_x86_64.tar.gz.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.apk +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.apk.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.deb +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.deb.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.rpm +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.rpm.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.apk +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.apk.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.deb +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.deb.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.rpm +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.rpm.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.tar.gz.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_x86_64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_x86_64.tar.gz.sbom.json +0 -1
- package/dist/dingo_darwin_amd64_v1/dingo +0 -0
- package/dist/dingo_darwin_arm64_v8.0/dingo +0 -0
- package/dist/dingo_linux_amd64_v1/dingo +0 -0
- package/dist/dingo_linux_arm64_v8.0/dingo +0 -0
- package/dist/homebrew/dingo.rb +0 -51
- package/dist/metadata.json +0 -1
- package/event/event.go +0 -141
- package/event/event_test.go +0 -115
- package/event/metrics.go +0 -44
- package/go.mod +0 -98
- package/go.sum +0 -358
- package/internal/config/config.go +0 -145
- package/internal/config/config_test.go +0 -118
- package/internal/node/load.go +0 -149
- package/internal/node/node.go +0 -176
- package/internal/version/version.go +0 -33
- package/ledger/certs.go +0 -164
- package/ledger/chainsync.go +0 -504
- package/ledger/delta.go +0 -99
- package/ledger/eras/allegra.go +0 -154
- package/ledger/eras/alonzo.go +0 -156
- package/ledger/eras/babbage.go +0 -154
- package/ledger/eras/byron.go +0 -42
- package/ledger/eras/conway.go +0 -166
- package/ledger/eras/eras.go +0 -44
- package/ledger/eras/mary.go +0 -154
- package/ledger/eras/shelley.go +0 -164
- package/ledger/error.go +0 -19
- package/ledger/event.go +0 -50
- package/ledger/metrics.go +0 -53
- package/ledger/queries.go +0 -258
- package/ledger/slot.go +0 -127
- package/ledger/slot_test.go +0 -147
- package/ledger/state.go +0 -821
- package/ledger/view.go +0 -73
- package/localstatequery.go +0 -50
- package/localtxmonitor.go +0 -44
- package/localtxsubmission.go +0 -52
- package/mempool/consumer.go +0 -98
- package/mempool/mempool.go +0 -322
- package/node.go +0 -320
- package/peergov/event.go +0 -27
- package/peergov/peer.go +0 -67
- package/peergov/peergov.go +0 -290
- package/peersharing.go +0 -70
- package/preview-local-topology.json +0 -23
- package/topology/topology.go +0 -69
- package/topology/topology_test.go +0 -179
- package/tracing.go +0 -65
- package/txsubmission.go +0 -233
- package/utxorpc/query.go +0 -311
- package/utxorpc/submit.go +0 -395
- package/utxorpc/sync.go +0 -276
- package/utxorpc/utxorpc.go +0 -166
- package/utxorpc/watch.go +0 -310
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package models
|
|
16
|
-
|
|
17
|
-
type ResignCommitteeCold struct {
|
|
18
|
-
ID uint `gorm:"primarykey"`
|
|
19
|
-
ColdCredential []byte `gorm:"index"`
|
|
20
|
-
AnchorUrl string
|
|
21
|
-
AnchorHash []byte
|
|
22
|
-
AddedSlot uint64
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
func (ResignCommitteeCold) TableName() string {
|
|
26
|
-
return "resign_committee_cold"
|
|
27
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package models
|
|
16
|
-
|
|
17
|
-
type StakeVoteDelegation struct {
|
|
18
|
-
ID uint `gorm:"primarykey"`
|
|
19
|
-
StakingKey []byte `gorm:"index"`
|
|
20
|
-
PoolKeyHash []byte `gorm:"index"`
|
|
21
|
-
Drep []byte `gorm:"index"`
|
|
22
|
-
AddedSlot uint64
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
func (StakeVoteDelegation) TableName() string {
|
|
26
|
-
return "stake_vote_delegation"
|
|
27
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package models
|
|
16
|
-
|
|
17
|
-
type Tip struct {
|
|
18
|
-
ID uint `gorm:"primarykey"`
|
|
19
|
-
Slot uint64
|
|
20
|
-
Hash []byte
|
|
21
|
-
BlockNumber uint64
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
func (Tip) TableName() string {
|
|
25
|
-
return "tip"
|
|
26
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package models
|
|
16
|
-
|
|
17
|
-
type UpdateDrep struct {
|
|
18
|
-
ID uint `gorm:"primarykey"`
|
|
19
|
-
Credential []byte `gorm:"index"`
|
|
20
|
-
AnchorUrl string
|
|
21
|
-
AnchorHash []byte
|
|
22
|
-
AddedSlot uint64
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
func (UpdateDrep) TableName() string {
|
|
26
|
-
return "update_drep"
|
|
27
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package models
|
|
16
|
-
|
|
17
|
-
type Utxo struct {
|
|
18
|
-
ID uint `gorm:"primarykey"`
|
|
19
|
-
TxId []byte `gorm:"index:tx_id_output_idx"`
|
|
20
|
-
OutputIdx uint32 `gorm:"index:tx_id_output_idx"`
|
|
21
|
-
AddedSlot uint64 `gorm:"index"`
|
|
22
|
-
DeletedSlot uint64 `gorm:"index"`
|
|
23
|
-
PaymentKey []byte `gorm:"index"`
|
|
24
|
-
StakingKey []byte `gorm:"index"`
|
|
25
|
-
Cbor []byte `gorm:"-"` // This is here for convenience but not represented in the metadata DB
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
func (u *Utxo) TableName() string {
|
|
29
|
-
return "utxo"
|
|
30
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package models
|
|
16
|
-
|
|
17
|
-
type VoteDelegation struct {
|
|
18
|
-
ID uint `gorm:"primarykey"`
|
|
19
|
-
StakingKey []byte `gorm:"index"`
|
|
20
|
-
Drep []byte `gorm:"index"`
|
|
21
|
-
AddedSlot uint64
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
func (VoteDelegation) TableName() string {
|
|
25
|
-
return "vote_delegation"
|
|
26
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package models
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package sqlite
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"errors"
|
|
19
|
-
|
|
20
|
-
"github.com/blinklabs-io/dingo/database/plugin/metadata/sqlite/models"
|
|
21
|
-
"github.com/blinklabs-io/dingo/database/types"
|
|
22
|
-
"github.com/blinklabs-io/gouroboros/cbor"
|
|
23
|
-
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
|
|
24
|
-
"gorm.io/gorm"
|
|
25
|
-
"gorm.io/gorm/clause"
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
// GetPool gets a pool
|
|
29
|
-
func (d *MetadataStoreSqlite) GetPool(
|
|
30
|
-
// pkh lcommon.PoolKeyHash,
|
|
31
|
-
pkh []byte,
|
|
32
|
-
txn *gorm.DB,
|
|
33
|
-
) (models.Pool, error) {
|
|
34
|
-
ret := models.Pool{}
|
|
35
|
-
tmpPool := models.Pool{}
|
|
36
|
-
if txn != nil {
|
|
37
|
-
result := txn.First(
|
|
38
|
-
&tmpPool,
|
|
39
|
-
"pool_key_hash = ?",
|
|
40
|
-
lcommon.Blake2b224(pkh).Bytes(),
|
|
41
|
-
)
|
|
42
|
-
if result.Error != nil {
|
|
43
|
-
return ret, result.Error
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
result := d.DB().First(&tmpPool, "pool_key_hash = ?", lcommon.Blake2b224(pkh).Bytes())
|
|
47
|
-
if result.Error != nil {
|
|
48
|
-
return ret, result.Error
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
ret = tmpPool
|
|
52
|
-
return ret, nil
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// GetPoolRegistrations returns pool registration certificates
|
|
56
|
-
func (d *MetadataStoreSqlite) GetPoolRegistrations(
|
|
57
|
-
pkh lcommon.PoolKeyHash,
|
|
58
|
-
txn *gorm.DB,
|
|
59
|
-
) ([]lcommon.PoolRegistrationCertificate, error) {
|
|
60
|
-
ret := []lcommon.PoolRegistrationCertificate{}
|
|
61
|
-
certs := []models.PoolRegistration{}
|
|
62
|
-
if txn != nil {
|
|
63
|
-
result := txn.Where("pool_key_hash = ?", lcommon.Blake2b224(pkh).Bytes()).
|
|
64
|
-
Order("id DESC").
|
|
65
|
-
Find(&certs)
|
|
66
|
-
if result.Error != nil {
|
|
67
|
-
return ret, result.Error
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
result := d.DB().Where("pool_key_hash = ?", lcommon.Blake2b224(pkh).Bytes()).
|
|
71
|
-
Order("id DESC").
|
|
72
|
-
Find(&certs)
|
|
73
|
-
if result.Error != nil {
|
|
74
|
-
return ret, result.Error
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
var addrKeyHash lcommon.AddrKeyHash
|
|
78
|
-
var tmpCert lcommon.PoolRegistrationCertificate
|
|
79
|
-
var tmpMargin cbor.Rat
|
|
80
|
-
var tmpRelay lcommon.PoolRelay
|
|
81
|
-
for _, cert := range certs {
|
|
82
|
-
tmpMargin = cbor.Rat{Rat: cert.Margin.Rat}
|
|
83
|
-
tmpCert = lcommon.PoolRegistrationCertificate{
|
|
84
|
-
CertType: lcommon.CertificateTypePoolRegistration,
|
|
85
|
-
Operator: lcommon.PoolKeyHash(
|
|
86
|
-
lcommon.NewBlake2b224(cert.PoolKeyHash),
|
|
87
|
-
),
|
|
88
|
-
VrfKeyHash: lcommon.VrfKeyHash(
|
|
89
|
-
lcommon.NewBlake2b256(cert.VrfKeyHash),
|
|
90
|
-
),
|
|
91
|
-
Pledge: uint64(cert.Pledge),
|
|
92
|
-
Cost: uint64(cert.Cost),
|
|
93
|
-
Margin: tmpMargin,
|
|
94
|
-
RewardAccount: lcommon.AddrKeyHash(
|
|
95
|
-
lcommon.NewBlake2b224(cert.RewardAccount),
|
|
96
|
-
),
|
|
97
|
-
}
|
|
98
|
-
for _, owner := range cert.Owners {
|
|
99
|
-
addrKeyHash = lcommon.AddrKeyHash(
|
|
100
|
-
lcommon.NewBlake2b224(owner.KeyHash),
|
|
101
|
-
)
|
|
102
|
-
tmpCert.PoolOwners = append(tmpCert.PoolOwners, addrKeyHash)
|
|
103
|
-
}
|
|
104
|
-
for _, relay := range cert.Relays {
|
|
105
|
-
tmpRelay = lcommon.PoolRelay{}
|
|
106
|
-
// Determine type
|
|
107
|
-
if relay.Port != 0 {
|
|
108
|
-
port := uint32(relay.Port) // #nosec G115
|
|
109
|
-
tmpRelay.Port = &port
|
|
110
|
-
if relay.Hostname != "" {
|
|
111
|
-
hostname := relay.Hostname
|
|
112
|
-
tmpRelay.Type = lcommon.PoolRelayTypeSingleHostName
|
|
113
|
-
tmpRelay.Hostname = &hostname
|
|
114
|
-
} else {
|
|
115
|
-
tmpRelay.Type = lcommon.PoolRelayTypeSingleHostAddress
|
|
116
|
-
tmpRelay.Ipv4 = relay.Ipv4
|
|
117
|
-
tmpRelay.Ipv6 = relay.Ipv6
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
hostname := relay.Hostname
|
|
121
|
-
tmpRelay.Type = lcommon.PoolRelayTypeMultiHostName
|
|
122
|
-
tmpRelay.Hostname = &hostname
|
|
123
|
-
}
|
|
124
|
-
tmpCert.Relays = append(tmpCert.Relays, tmpRelay)
|
|
125
|
-
}
|
|
126
|
-
if cert.MetadataUrl != "" {
|
|
127
|
-
poolMetadata := &lcommon.PoolMetadata{
|
|
128
|
-
Url: cert.MetadataUrl,
|
|
129
|
-
Hash: lcommon.PoolMetadataHash(
|
|
130
|
-
lcommon.NewBlake2b256(cert.MetadataHash),
|
|
131
|
-
),
|
|
132
|
-
}
|
|
133
|
-
tmpCert.PoolMetadata = poolMetadata
|
|
134
|
-
}
|
|
135
|
-
ret = append(ret, tmpCert)
|
|
136
|
-
}
|
|
137
|
-
return ret, nil
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// SetPoolRegistration saves a pool registration certificate and pool
|
|
141
|
-
func (d *MetadataStoreSqlite) SetPoolRegistration(
|
|
142
|
-
cert *lcommon.PoolRegistrationCertificate,
|
|
143
|
-
slot, deposit uint64,
|
|
144
|
-
txn *gorm.DB,
|
|
145
|
-
) error {
|
|
146
|
-
var tmpItem models.Pool
|
|
147
|
-
tmpPool, err := d.GetPool(cert.Operator[:], txn)
|
|
148
|
-
if err != nil {
|
|
149
|
-
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
150
|
-
tmpItem = models.Pool{
|
|
151
|
-
PoolKeyHash: cert.Operator[:],
|
|
152
|
-
VrfKeyHash: cert.VrfKeyHash[:],
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
return err
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
// Store our fetched pool
|
|
159
|
-
tmpItem = tmpPool
|
|
160
|
-
}
|
|
161
|
-
tmpItem.Pledge = types.Uint64(cert.Pledge)
|
|
162
|
-
tmpItem.Cost = types.Uint64(cert.Cost)
|
|
163
|
-
tmpItem.Margin = &types.Rat{Rat: cert.Margin.Rat}
|
|
164
|
-
tmpItem.RewardAccount = cert.RewardAccount[:]
|
|
165
|
-
|
|
166
|
-
tmpReg := models.PoolRegistration{
|
|
167
|
-
PoolKeyHash: cert.Operator[:],
|
|
168
|
-
VrfKeyHash: cert.VrfKeyHash[:],
|
|
169
|
-
Pledge: types.Uint64(cert.Pledge),
|
|
170
|
-
Cost: types.Uint64(cert.Cost),
|
|
171
|
-
Margin: &types.Rat{Rat: cert.Margin.Rat},
|
|
172
|
-
AddedSlot: slot,
|
|
173
|
-
DepositAmount: deposit,
|
|
174
|
-
}
|
|
175
|
-
if cert.PoolMetadata != nil {
|
|
176
|
-
tmpReg.MetadataUrl = cert.PoolMetadata.Url
|
|
177
|
-
tmpReg.MetadataHash = cert.PoolMetadata.Hash[:]
|
|
178
|
-
}
|
|
179
|
-
for _, owner := range cert.PoolOwners {
|
|
180
|
-
tmpReg.Owners = append(
|
|
181
|
-
tmpReg.Owners,
|
|
182
|
-
models.PoolRegistrationOwner{KeyHash: owner[:]},
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
tmpItem.Owners = tmpReg.Owners
|
|
186
|
-
var tmpRelay models.PoolRegistrationRelay
|
|
187
|
-
for _, relay := range cert.Relays {
|
|
188
|
-
tmpRelay = models.PoolRegistrationRelay{
|
|
189
|
-
Ipv4: relay.Ipv4,
|
|
190
|
-
Ipv6: relay.Ipv6,
|
|
191
|
-
}
|
|
192
|
-
if relay.Port != nil {
|
|
193
|
-
tmpRelay.Port = uint(*relay.Port)
|
|
194
|
-
}
|
|
195
|
-
if relay.Hostname != nil {
|
|
196
|
-
tmpRelay.Hostname = *relay.Hostname
|
|
197
|
-
}
|
|
198
|
-
tmpItem.Relays = append(tmpReg.Relays, tmpRelay)
|
|
199
|
-
}
|
|
200
|
-
tmpItem.Registration = append(tmpItem.Registration, tmpReg)
|
|
201
|
-
tmpItem.Relays = tmpReg.Relays
|
|
202
|
-
if txn != nil {
|
|
203
|
-
if result := txn.Clauses(clause.OnConflict{UpdateAll: true}).Create(&tmpItem); result.Error != nil {
|
|
204
|
-
return result.Error
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
if result := d.DB().Clauses(clause.OnConflict{UpdateAll: true}).Create(&tmpItem); result.Error != nil {
|
|
208
|
-
return result.Error
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return nil
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// SetPoolRetirement saves a pool retirement certificate
|
|
215
|
-
func (d *MetadataStoreSqlite) SetPoolRetirement(
|
|
216
|
-
cert *lcommon.PoolRetirementCertificate,
|
|
217
|
-
slot uint64,
|
|
218
|
-
txn *gorm.DB,
|
|
219
|
-
) error {
|
|
220
|
-
tmpPool, err := d.GetPool(cert.PoolKeyHash[:], txn)
|
|
221
|
-
if err != nil {
|
|
222
|
-
return err
|
|
223
|
-
}
|
|
224
|
-
tmpItem := models.PoolRetirement{
|
|
225
|
-
PoolKeyHash: cert.PoolKeyHash[:],
|
|
226
|
-
Epoch: cert.Epoch,
|
|
227
|
-
AddedSlot: slot,
|
|
228
|
-
}
|
|
229
|
-
tmpPool.Retirement = append(tmpPool.Retirement, tmpItem)
|
|
230
|
-
if txn != nil {
|
|
231
|
-
if result := txn.Save(&tmpPool); result.Error != nil {
|
|
232
|
-
return result.Error
|
|
233
|
-
}
|
|
234
|
-
} else {
|
|
235
|
-
if result := d.DB().Save(&tmpPool); result.Error != nil {
|
|
236
|
-
return result.Error
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return nil
|
|
240
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package sqlite
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"github.com/blinklabs-io/dingo/database/plugin/metadata/sqlite/models"
|
|
19
|
-
"gorm.io/gorm"
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
// GetPParams returns a list of protocol parameters for a given epoch. If there are no pparams
|
|
23
|
-
// for the specified epoch, it will return the most recent pparams before the specified epoch
|
|
24
|
-
func (d *MetadataStoreSqlite) GetPParams(
|
|
25
|
-
epoch uint64,
|
|
26
|
-
txn *gorm.DB,
|
|
27
|
-
) ([]models.PParams, error) {
|
|
28
|
-
ret := []models.PParams{}
|
|
29
|
-
if txn != nil {
|
|
30
|
-
result := txn.Where("epoch <= ?", epoch).Order("id DESC").Find(&ret)
|
|
31
|
-
if result.Error != nil {
|
|
32
|
-
return ret, result.Error
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
result := d.DB().Where("epoch <= ?", epoch).Order("id DESC").Find(&ret)
|
|
36
|
-
if result.Error != nil {
|
|
37
|
-
return ret, result.Error
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return ret, nil
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// GetPParamUpdates returns a list of protocol parameter updates for a given epoch
|
|
44
|
-
func (d *MetadataStoreSqlite) GetPParamUpdates(
|
|
45
|
-
epoch uint64,
|
|
46
|
-
txn *gorm.DB,
|
|
47
|
-
) ([]models.PParamUpdate, error) {
|
|
48
|
-
ret := []models.PParamUpdate{}
|
|
49
|
-
if txn != nil {
|
|
50
|
-
result := txn.Where("epoch = ?", epoch).Order("id DESC").Find(&ret)
|
|
51
|
-
if result.Error != nil {
|
|
52
|
-
return ret, result.Error
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
result := d.DB().Where("epoch = ?", epoch).Order("id DESC").Find(&ret)
|
|
56
|
-
if result.Error != nil {
|
|
57
|
-
return ret, result.Error
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return ret, nil
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// SetPParams saves protocol parameters
|
|
64
|
-
func (d *MetadataStoreSqlite) SetPParams(
|
|
65
|
-
params []byte,
|
|
66
|
-
slot, epoch uint64,
|
|
67
|
-
eraId uint,
|
|
68
|
-
txn *gorm.DB,
|
|
69
|
-
) error {
|
|
70
|
-
tmpItem := models.PParams{
|
|
71
|
-
Cbor: params,
|
|
72
|
-
AddedSlot: slot,
|
|
73
|
-
Epoch: epoch,
|
|
74
|
-
EraId: eraId,
|
|
75
|
-
}
|
|
76
|
-
if txn != nil {
|
|
77
|
-
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
78
|
-
return result.Error
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
82
|
-
return result.Error
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return nil
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// SetPParamUpdate saves a protocol parameter update
|
|
89
|
-
func (d *MetadataStoreSqlite) SetPParamUpdate(
|
|
90
|
-
genesis, update []byte,
|
|
91
|
-
slot, epoch uint64,
|
|
92
|
-
txn *gorm.DB,
|
|
93
|
-
) error {
|
|
94
|
-
tmpItem := models.PParamUpdate{
|
|
95
|
-
GenesisHash: genesis,
|
|
96
|
-
Cbor: update,
|
|
97
|
-
AddedSlot: slot,
|
|
98
|
-
Epoch: epoch,
|
|
99
|
-
}
|
|
100
|
-
if txn != nil {
|
|
101
|
-
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
102
|
-
return result.Error
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
106
|
-
return result.Error
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return nil
|
|
110
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package sqlite
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"errors"
|
|
19
|
-
|
|
20
|
-
"github.com/blinklabs-io/dingo/database/plugin/metadata/sqlite/models"
|
|
21
|
-
ochainsync "github.com/blinklabs-io/gouroboros/protocol/chainsync"
|
|
22
|
-
ocommon "github.com/blinklabs-io/gouroboros/protocol/common"
|
|
23
|
-
"gorm.io/gorm"
|
|
24
|
-
"gorm.io/gorm/clause"
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
const (
|
|
28
|
-
tipEntryId = 1
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
// GetTip returns the current metadata Tip as ocommon.Tip
|
|
32
|
-
func (d *MetadataStoreSqlite) GetTip(
|
|
33
|
-
txn *gorm.DB,
|
|
34
|
-
) (ocommon.Tip, error) {
|
|
35
|
-
ret := ocommon.Tip{}
|
|
36
|
-
tmpTip := models.Tip{}
|
|
37
|
-
if txn != nil {
|
|
38
|
-
result := txn.Where("id = ?", tipEntryId).First(&tmpTip)
|
|
39
|
-
if result.Error != nil {
|
|
40
|
-
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
|
41
|
-
return ret, nil
|
|
42
|
-
}
|
|
43
|
-
return ret, result.Error
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
result := d.DB().Where("id = ?", tipEntryId).First(&tmpTip)
|
|
47
|
-
if result.Error != nil {
|
|
48
|
-
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
|
49
|
-
return ret, nil
|
|
50
|
-
}
|
|
51
|
-
return ret, result.Error
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
ret.Point = ocommon.Point{
|
|
55
|
-
Slot: tmpTip.Slot,
|
|
56
|
-
Hash: tmpTip.Hash,
|
|
57
|
-
}
|
|
58
|
-
ret.BlockNumber = tmpTip.BlockNumber
|
|
59
|
-
return ret, nil
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// SetTip saves a tip
|
|
63
|
-
func (d *MetadataStoreSqlite) SetTip(
|
|
64
|
-
tip ochainsync.Tip,
|
|
65
|
-
txn *gorm.DB,
|
|
66
|
-
) error {
|
|
67
|
-
tmpItem := models.Tip{
|
|
68
|
-
ID: tipEntryId,
|
|
69
|
-
Slot: tip.Point.Slot,
|
|
70
|
-
Hash: tip.Point.Hash,
|
|
71
|
-
BlockNumber: tip.BlockNumber,
|
|
72
|
-
}
|
|
73
|
-
if txn != nil {
|
|
74
|
-
if result := txn.Clauses(clause.OnConflict{UpdateAll: true}).Create(&tmpItem); result.Error != nil {
|
|
75
|
-
return result.Error
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
if result := d.DB().Clauses(clause.OnConflict{UpdateAll: true}).Create(&tmpItem); result.Error != nil {
|
|
79
|
-
return result.Error
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return nil
|
|
83
|
-
}
|