@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
package/chainsync/chainsync.go
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 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 chainsync
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"sync"
|
|
19
|
-
|
|
20
|
-
"github.com/blinklabs-io/dingo/chain"
|
|
21
|
-
"github.com/blinklabs-io/dingo/event"
|
|
22
|
-
"github.com/blinklabs-io/dingo/ledger"
|
|
23
|
-
ouroboros "github.com/blinklabs-io/gouroboros"
|
|
24
|
-
"github.com/blinklabs-io/gouroboros/connection"
|
|
25
|
-
ocommon "github.com/blinklabs-io/gouroboros/protocol/common"
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
type ChainsyncClientState struct {
|
|
29
|
-
Cursor ocommon.Point
|
|
30
|
-
ChainIter *chain.ChainIterator
|
|
31
|
-
NeedsInitialRollback bool
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type State struct {
|
|
35
|
-
sync.Mutex
|
|
36
|
-
eventBus *event.EventBus
|
|
37
|
-
ledgerState *ledger.LedgerState
|
|
38
|
-
clients map[ouroboros.ConnectionId]*ChainsyncClientState
|
|
39
|
-
clientConnId *ouroboros.ConnectionId // TODO: replace with handling of multiple chainsync clients (#385)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
func NewState(
|
|
43
|
-
eventBus *event.EventBus,
|
|
44
|
-
ledgerState *ledger.LedgerState,
|
|
45
|
-
) *State {
|
|
46
|
-
s := &State{
|
|
47
|
-
eventBus: eventBus,
|
|
48
|
-
ledgerState: ledgerState,
|
|
49
|
-
clients: make(map[ouroboros.ConnectionId]*ChainsyncClientState),
|
|
50
|
-
}
|
|
51
|
-
return s
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
func (s *State) AddClient(
|
|
55
|
-
connId connection.ConnectionId,
|
|
56
|
-
intersectPoint ocommon.Point,
|
|
57
|
-
) (*ChainsyncClientState, error) {
|
|
58
|
-
s.Lock()
|
|
59
|
-
defer s.Unlock()
|
|
60
|
-
// Create initial chainsync state for connection
|
|
61
|
-
chainIter, err := s.ledgerState.GetChainFromPoint(intersectPoint, false)
|
|
62
|
-
if err != nil {
|
|
63
|
-
return nil, err
|
|
64
|
-
}
|
|
65
|
-
if _, ok := s.clients[connId]; !ok {
|
|
66
|
-
s.clients[connId] = &ChainsyncClientState{
|
|
67
|
-
Cursor: intersectPoint,
|
|
68
|
-
ChainIter: chainIter,
|
|
69
|
-
NeedsInitialRollback: true,
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return s.clients[connId], nil
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
func (s *State) RemoveClient(connId connection.ConnectionId) {
|
|
76
|
-
s.Lock()
|
|
77
|
-
defer s.Unlock()
|
|
78
|
-
// Remove client state entry
|
|
79
|
-
delete(s.clients, connId)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// TODO: replace with handling of multiple chainsync clients (#385)
|
|
83
|
-
func (s *State) GetClientConnId() *ouroboros.ConnectionId {
|
|
84
|
-
return s.clientConnId
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// TODO: replace with handling of multiple chainsync clients (#385)
|
|
88
|
-
func (s *State) SetClientConnId(connId ouroboros.ConnectionId) {
|
|
89
|
-
s.clientConnId = &connId
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// TODO: replace with handling of multiple chainsync clients (#385)
|
|
93
|
-
func (s *State) RemoveClientConnId(connId ouroboros.ConnectionId) {
|
|
94
|
-
if s.clientConnId != nil && *s.clientConnId == connId {
|
|
95
|
-
s.clientConnId = nil
|
|
96
|
-
}
|
|
97
|
-
}
|
package/chainsync.go
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 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 dingo
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"fmt"
|
|
19
|
-
|
|
20
|
-
"github.com/blinklabs-io/dingo/event"
|
|
21
|
-
"github.com/blinklabs-io/dingo/ledger"
|
|
22
|
-
ouroboros "github.com/blinklabs-io/gouroboros"
|
|
23
|
-
gledger "github.com/blinklabs-io/gouroboros/ledger"
|
|
24
|
-
ochainsync "github.com/blinklabs-io/gouroboros/protocol/chainsync"
|
|
25
|
-
ocommon "github.com/blinklabs-io/gouroboros/protocol/common"
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
const (
|
|
29
|
-
chainsyncIntersectPointCount = 100
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
func (n *Node) chainsyncServerConnOpts() []ochainsync.ChainSyncOptionFunc {
|
|
33
|
-
return []ochainsync.ChainSyncOptionFunc{
|
|
34
|
-
ochainsync.WithFindIntersectFunc(n.chainsyncServerFindIntersect),
|
|
35
|
-
ochainsync.WithRequestNextFunc(n.chainsyncServerRequestNext),
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
func (n *Node) chainsyncClientConnOpts() []ochainsync.ChainSyncOptionFunc {
|
|
40
|
-
return []ochainsync.ChainSyncOptionFunc{
|
|
41
|
-
ochainsync.WithRollForwardFunc(n.chainsyncClientRollForward),
|
|
42
|
-
ochainsync.WithRollBackwardFunc(n.chainsyncClientRollBackward),
|
|
43
|
-
// Enable pipelining of RequestNext messages to speed up chainsync
|
|
44
|
-
ochainsync.WithPipelineLimit(50),
|
|
45
|
-
// Set the recv queue size to 2x our pipeline limit
|
|
46
|
-
ochainsync.WithRecvQueueSize(100),
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
func (n *Node) chainsyncClientStart(connId ouroboros.ConnectionId) error {
|
|
51
|
-
conn := n.connManager.GetConnectionById(connId)
|
|
52
|
-
if conn == nil {
|
|
53
|
-
return fmt.Errorf("failed to lookup connection ID: %s", connId.String())
|
|
54
|
-
}
|
|
55
|
-
intersectPoints, err := n.ledgerState.RecentChainPoints(
|
|
56
|
-
chainsyncIntersectPointCount,
|
|
57
|
-
)
|
|
58
|
-
if err != nil {
|
|
59
|
-
return err
|
|
60
|
-
}
|
|
61
|
-
// Determine start point if we have no stored chain points
|
|
62
|
-
if len(intersectPoints) == 0 {
|
|
63
|
-
if n.config.intersectTip {
|
|
64
|
-
// Start initial chainsync from current chain tip
|
|
65
|
-
tip, err := conn.ChainSync().Client.GetCurrentTip()
|
|
66
|
-
if err != nil {
|
|
67
|
-
return err
|
|
68
|
-
}
|
|
69
|
-
intersectPoints = append(
|
|
70
|
-
intersectPoints,
|
|
71
|
-
tip.Point,
|
|
72
|
-
)
|
|
73
|
-
return conn.ChainSync().Client.Sync(intersectPoints)
|
|
74
|
-
} else if len(n.config.intersectPoints) > 0 {
|
|
75
|
-
// Start initial chainsync at specific point(s)
|
|
76
|
-
intersectPoints = append(
|
|
77
|
-
intersectPoints,
|
|
78
|
-
n.config.intersectPoints...,
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return conn.ChainSync().Client.Sync(intersectPoints)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
func (n *Node) chainsyncServerFindIntersect(
|
|
86
|
-
ctx ochainsync.CallbackContext,
|
|
87
|
-
points []ocommon.Point,
|
|
88
|
-
) (ocommon.Point, ochainsync.Tip, error) {
|
|
89
|
-
n.ledgerState.RLock()
|
|
90
|
-
defer n.ledgerState.RUnlock()
|
|
91
|
-
var retPoint ocommon.Point
|
|
92
|
-
var retTip ochainsync.Tip
|
|
93
|
-
// Find intersection
|
|
94
|
-
intersectPoint, err := n.ledgerState.GetIntersectPoint(points)
|
|
95
|
-
if err != nil {
|
|
96
|
-
return retPoint, retTip, err
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Populate return tip
|
|
100
|
-
retTip = n.ledgerState.Tip()
|
|
101
|
-
|
|
102
|
-
if intersectPoint == nil {
|
|
103
|
-
return retPoint, retTip, ochainsync.ErrIntersectNotFound
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Add our client to the chainsync state
|
|
107
|
-
_, err = n.chainsyncState.AddClient(
|
|
108
|
-
ctx.ConnectionId,
|
|
109
|
-
*intersectPoint,
|
|
110
|
-
)
|
|
111
|
-
if err != nil {
|
|
112
|
-
return retPoint, retTip, err
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Populate return point
|
|
116
|
-
retPoint = *intersectPoint
|
|
117
|
-
|
|
118
|
-
return retPoint, retTip, nil
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
func (n *Node) chainsyncServerRequestNext(
|
|
122
|
-
ctx ochainsync.CallbackContext,
|
|
123
|
-
) error {
|
|
124
|
-
// Create/retrieve chainsync state for connection
|
|
125
|
-
tip := n.ledgerState.Tip()
|
|
126
|
-
clientState, err := n.chainsyncState.AddClient(
|
|
127
|
-
ctx.ConnectionId,
|
|
128
|
-
tip.Point,
|
|
129
|
-
)
|
|
130
|
-
if err != nil {
|
|
131
|
-
return err
|
|
132
|
-
}
|
|
133
|
-
if clientState.NeedsInitialRollback {
|
|
134
|
-
err := ctx.Server.RollBackward(
|
|
135
|
-
clientState.Cursor,
|
|
136
|
-
tip,
|
|
137
|
-
)
|
|
138
|
-
if err != nil {
|
|
139
|
-
return err
|
|
140
|
-
}
|
|
141
|
-
clientState.NeedsInitialRollback = false
|
|
142
|
-
return nil
|
|
143
|
-
}
|
|
144
|
-
// Check for available block
|
|
145
|
-
next, err := clientState.ChainIter.Next(false)
|
|
146
|
-
if err != nil {
|
|
147
|
-
return err
|
|
148
|
-
}
|
|
149
|
-
if next != nil {
|
|
150
|
-
return ctx.Server.RollForward(
|
|
151
|
-
next.Block.Type,
|
|
152
|
-
next.Block.Cbor,
|
|
153
|
-
tip,
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
// Send AwaitReply
|
|
157
|
-
if err := ctx.Server.AwaitReply(); err != nil {
|
|
158
|
-
return err
|
|
159
|
-
}
|
|
160
|
-
// Wait for next block and send
|
|
161
|
-
go func() {
|
|
162
|
-
next, _ := clientState.ChainIter.Next(true)
|
|
163
|
-
if next == nil {
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
tip := n.ledgerState.Tip()
|
|
167
|
-
_ = ctx.Server.RollForward(
|
|
168
|
-
next.Block.Type,
|
|
169
|
-
next.Block.Cbor,
|
|
170
|
-
tip,
|
|
171
|
-
)
|
|
172
|
-
}()
|
|
173
|
-
return nil
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
func (n *Node) chainsyncClientRollBackward(
|
|
177
|
-
ctx ochainsync.CallbackContext,
|
|
178
|
-
point ocommon.Point,
|
|
179
|
-
tip ochainsync.Tip,
|
|
180
|
-
) error {
|
|
181
|
-
// Generate event
|
|
182
|
-
n.eventBus.Publish(
|
|
183
|
-
ledger.ChainsyncEventType,
|
|
184
|
-
event.NewEvent(
|
|
185
|
-
ledger.ChainsyncEventType,
|
|
186
|
-
ledger.ChainsyncEvent{
|
|
187
|
-
Rollback: true,
|
|
188
|
-
Point: point,
|
|
189
|
-
Tip: tip,
|
|
190
|
-
},
|
|
191
|
-
),
|
|
192
|
-
)
|
|
193
|
-
return nil
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
func (n *Node) chainsyncClientRollForward(
|
|
197
|
-
ctx ochainsync.CallbackContext,
|
|
198
|
-
blockType uint,
|
|
199
|
-
blockData interface{},
|
|
200
|
-
tip ochainsync.Tip,
|
|
201
|
-
) error {
|
|
202
|
-
switch v := blockData.(type) {
|
|
203
|
-
case gledger.BlockHeader:
|
|
204
|
-
blockSlot := v.SlotNumber()
|
|
205
|
-
blockHash := v.Hash().Bytes()
|
|
206
|
-
n.eventBus.Publish(
|
|
207
|
-
ledger.ChainsyncEventType,
|
|
208
|
-
event.NewEvent(
|
|
209
|
-
ledger.ChainsyncEventType,
|
|
210
|
-
ledger.ChainsyncEvent{
|
|
211
|
-
ConnectionId: ctx.ConnectionId,
|
|
212
|
-
Point: ocommon.NewPoint(blockSlot, blockHash),
|
|
213
|
-
Type: blockType,
|
|
214
|
-
BlockHeader: v,
|
|
215
|
-
Tip: tip,
|
|
216
|
-
},
|
|
217
|
-
),
|
|
218
|
-
)
|
|
219
|
-
default:
|
|
220
|
-
return fmt.Errorf("unexpected block data type: %T", v)
|
|
221
|
-
}
|
|
222
|
-
return nil
|
|
223
|
-
}
|
package/cmd/dingo/load.go
DELETED
|
@@ -1,52 +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 main
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"log/slog"
|
|
19
|
-
"os"
|
|
20
|
-
|
|
21
|
-
"github.com/blinklabs-io/dingo/internal/config"
|
|
22
|
-
"github.com/blinklabs-io/dingo/internal/node"
|
|
23
|
-
"github.com/spf13/cobra"
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
func loadRun(_ *cobra.Command, args []string, cfg *config.Config) {
|
|
27
|
-
if len(args) != 1 {
|
|
28
|
-
slog.Error("you must provide the path to an ImmutableDB")
|
|
29
|
-
os.Exit(1)
|
|
30
|
-
}
|
|
31
|
-
logger := commonRun()
|
|
32
|
-
if err := node.Load(cfg, logger, args[0]); err != nil {
|
|
33
|
-
slog.Error(err.Error())
|
|
34
|
-
os.Exit(1)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
func loadCommand() *cobra.Command {
|
|
39
|
-
cmd := &cobra.Command{
|
|
40
|
-
Use: "load db-path",
|
|
41
|
-
Short: "Load blocks from ImmutableDB",
|
|
42
|
-
Run: func(cmd *cobra.Command, args []string) {
|
|
43
|
-
cfg := config.FromContext(cmd.Context())
|
|
44
|
-
if cfg == nil {
|
|
45
|
-
slog.Error("no config found in context")
|
|
46
|
-
os.Exit(1)
|
|
47
|
-
}
|
|
48
|
-
loadRun(cmd, args, cfg)
|
|
49
|
-
},
|
|
50
|
-
}
|
|
51
|
-
return cmd
|
|
52
|
-
}
|
package/cmd/dingo/main.go
DELETED
|
@@ -1,118 +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 main
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"fmt"
|
|
19
|
-
"log/slog"
|
|
20
|
-
"os"
|
|
21
|
-
|
|
22
|
-
"github.com/blinklabs-io/dingo/internal/config"
|
|
23
|
-
"github.com/blinklabs-io/dingo/internal/version"
|
|
24
|
-
"github.com/spf13/cobra"
|
|
25
|
-
"go.uber.org/automaxprocs/maxprocs"
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
const (
|
|
29
|
-
programName = "dingo"
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
func slogPrintf(format string, v ...any) {
|
|
33
|
-
slog.Info(fmt.Sprintf(format, v...),
|
|
34
|
-
"component", programName,
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var (
|
|
39
|
-
globalFlags = struct {
|
|
40
|
-
version bool
|
|
41
|
-
debug bool
|
|
42
|
-
}{}
|
|
43
|
-
configFile string
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
func commonRun() *slog.Logger {
|
|
47
|
-
if globalFlags.version {
|
|
48
|
-
fmt.Printf("%s %s\n", programName, version.GetVersionString())
|
|
49
|
-
os.Exit(0)
|
|
50
|
-
}
|
|
51
|
-
// Configure logger
|
|
52
|
-
logLevel := slog.LevelInfo
|
|
53
|
-
addSource := false
|
|
54
|
-
if globalFlags.debug {
|
|
55
|
-
logLevel = slog.LevelDebug
|
|
56
|
-
// addSource = true
|
|
57
|
-
}
|
|
58
|
-
logger := slog.New(
|
|
59
|
-
slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
|
60
|
-
AddSource: addSource,
|
|
61
|
-
Level: logLevel,
|
|
62
|
-
}),
|
|
63
|
-
)
|
|
64
|
-
slog.SetDefault(logger)
|
|
65
|
-
// Configure max processes with our logger wrapper, toss undo func
|
|
66
|
-
_, err := maxprocs.Set(maxprocs.Logger(slogPrintf))
|
|
67
|
-
if err != nil {
|
|
68
|
-
// If we hit this, something really wrong happened
|
|
69
|
-
slog.Error(err.Error())
|
|
70
|
-
os.Exit(1)
|
|
71
|
-
}
|
|
72
|
-
logger.Info(
|
|
73
|
-
"version: "+version.GetVersionString(),
|
|
74
|
-
"component", programName,
|
|
75
|
-
)
|
|
76
|
-
return logger
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
func main() {
|
|
80
|
-
rootCmd := &cobra.Command{
|
|
81
|
-
Use: programName,
|
|
82
|
-
Run: func(cmd *cobra.Command, args []string) {
|
|
83
|
-
cfg := config.FromContext(cmd.Context())
|
|
84
|
-
if cfg == nil {
|
|
85
|
-
slog.Error("no config found in context")
|
|
86
|
-
os.Exit(1)
|
|
87
|
-
}
|
|
88
|
-
serveRun(cmd, args, cfg)
|
|
89
|
-
},
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Global flags
|
|
93
|
-
rootCmd.PersistentFlags().
|
|
94
|
-
BoolVarP(&globalFlags.debug, "debug", "D", false, "enable debug logging")
|
|
95
|
-
rootCmd.PersistentFlags().
|
|
96
|
-
BoolVarP(&globalFlags.version, "version", "", false, "show version and exit")
|
|
97
|
-
rootCmd.PersistentFlags().
|
|
98
|
-
StringVar(&configFile, "config", "", "path to config file")
|
|
99
|
-
|
|
100
|
-
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
|
|
101
|
-
cfg, err := config.LoadConfig(configFile)
|
|
102
|
-
if err != nil {
|
|
103
|
-
return fmt.Errorf("failed to load config: %w", err)
|
|
104
|
-
}
|
|
105
|
-
cmd.SetContext(config.WithContext(cmd.Context(), cfg))
|
|
106
|
-
return nil
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Subcommands
|
|
110
|
-
rootCmd.AddCommand(serveCommand())
|
|
111
|
-
rootCmd.AddCommand(loadCommand())
|
|
112
|
-
|
|
113
|
-
// Execute cobra command
|
|
114
|
-
if err := rootCmd.Execute(); err != nil {
|
|
115
|
-
// NOTE: we purposely don't display the error, since cobra will have already displayed it
|
|
116
|
-
os.Exit(1)
|
|
117
|
-
}
|
|
118
|
-
}
|
package/cmd/dingo/serve.go
DELETED
|
@@ -1,49 +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 main
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"log/slog"
|
|
19
|
-
"os"
|
|
20
|
-
|
|
21
|
-
"github.com/blinklabs-io/dingo/internal/config"
|
|
22
|
-
"github.com/blinklabs-io/dingo/internal/node"
|
|
23
|
-
"github.com/spf13/cobra"
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
func serveRun(_ *cobra.Command, _ []string, cfg *config.Config) {
|
|
27
|
-
logger := commonRun()
|
|
28
|
-
// Run node
|
|
29
|
-
if err := node.Run(cfg, logger); err != nil {
|
|
30
|
-
slog.Error(err.Error())
|
|
31
|
-
os.Exit(1)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
func serveCommand() *cobra.Command {
|
|
36
|
-
cmd := &cobra.Command{
|
|
37
|
-
Use: "serve",
|
|
38
|
-
Short: "Run as a node",
|
|
39
|
-
Run: func(cmd *cobra.Command, args []string) {
|
|
40
|
-
cfg := config.FromContext(cmd.Context())
|
|
41
|
-
if cfg == nil {
|
|
42
|
-
slog.Error("no config found in context")
|
|
43
|
-
os.Exit(1)
|
|
44
|
-
}
|
|
45
|
-
serveRun(cmd, args, cfg)
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
return cmd
|
|
49
|
-
}
|