@blinklabs/dingo 0.6.0 → 0.7.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/bin/dingo +0 -0
- package/database/account.go +42 -0
- package/database/drep.go +28 -8
- package/database/plugin/metadata/sqlite/account.go +116 -27
- package/database/plugin/metadata/sqlite/drep.go +140 -0
- package/database/plugin/metadata/sqlite/models/account.go +37 -0
- package/database/plugin/metadata/sqlite/models/drep.go +25 -0
- package/database/plugin/metadata/sqlite/models/models.go +1 -0
- package/database/plugin/metadata/sqlite/models/vote_registration_delegation.go +0 -11
- package/database/plugin/metadata/store.go +30 -0
- package/go.mod +1 -1
- package/go.sum +2 -2
- package/ledger/certs.go +53 -2
- package/ledger/chainsync.go +68 -142
- package/ledger/delta.go +99 -0
- package/ledger/eras/conway.go +8 -0
- package/ledger/queries.go +2 -4
- package/ledger/state.go +177 -82
- package/package.json +5 -5
- package/database/plugin/metadata/sqlite/models/deregistration_drep.go +0 -26
- package/database/plugin/metadata/sqlite/models/registration_drep.go +0 -28
- package/database/plugin/metadata/sqlite/models/stake_registration_delegation.go +0 -27
- package/database/plugin/metadata/sqlite/models/stake_vote_registration_delegation.go +0 -27
package/bin/dingo
ADDED
|
Binary file
|
package/database/account.go
CHANGED
|
@@ -136,3 +136,45 @@ func (d *Database) SetStakeRegistration(
|
|
|
136
136
|
txn.Metadata(),
|
|
137
137
|
)
|
|
138
138
|
}
|
|
139
|
+
|
|
140
|
+
// SetStakeRegistrationDelegation saves a stake registration delegation certificate
|
|
141
|
+
func (d *Database) SetStakeRegistrationDelegation(
|
|
142
|
+
cert *lcommon.StakeRegistrationDelegationCertificate,
|
|
143
|
+
slot, deposit uint64,
|
|
144
|
+
txn *Txn,
|
|
145
|
+
) error {
|
|
146
|
+
return d.metadata.SetStakeRegistrationDelegation(
|
|
147
|
+
cert,
|
|
148
|
+
slot,
|
|
149
|
+
deposit,
|
|
150
|
+
txn.Metadata(),
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// SetStakeVoteRegistrationDelegation saves a stake vote registration delegation certificate
|
|
155
|
+
func (d *Database) SetStakeVoteRegistrationDelegation(
|
|
156
|
+
cert *lcommon.StakeVoteRegistrationDelegationCertificate,
|
|
157
|
+
slot, deposit uint64,
|
|
158
|
+
txn *Txn,
|
|
159
|
+
) error {
|
|
160
|
+
return d.metadata.SetStakeVoteRegistrationDelegation(
|
|
161
|
+
cert,
|
|
162
|
+
slot,
|
|
163
|
+
deposit,
|
|
164
|
+
txn.Metadata(),
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// SetVoteRegistrationDelegation saves a vote registration delegation certificate
|
|
169
|
+
func (d *Database) SetVoteRegistrationDelegation(
|
|
170
|
+
cert *lcommon.VoteRegistrationDelegationCertificate,
|
|
171
|
+
slot, deposit uint64,
|
|
172
|
+
txn *Txn,
|
|
173
|
+
) error {
|
|
174
|
+
return d.metadata.SetVoteRegistrationDelegation(
|
|
175
|
+
cert,
|
|
176
|
+
slot,
|
|
177
|
+
deposit,
|
|
178
|
+
txn.Metadata(),
|
|
179
|
+
)
|
|
180
|
+
}
|
package/database/drep.go
CHANGED
|
@@ -14,14 +14,34 @@
|
|
|
14
14
|
|
|
15
15
|
package database
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
import (
|
|
18
|
+
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
// SetRegistrationDrep saves a registration drep certificate
|
|
22
|
+
func (d *Database) SetRegistrationDrep(
|
|
23
|
+
cert *lcommon.RegistrationDrepCertificate,
|
|
24
|
+
slot, deposit uint64,
|
|
25
|
+
txn *Txn,
|
|
26
|
+
) error {
|
|
27
|
+
return d.metadata.SetRegistrationDrep(
|
|
28
|
+
cert,
|
|
29
|
+
slot,
|
|
30
|
+
deposit,
|
|
31
|
+
txn.Metadata(),
|
|
32
|
+
)
|
|
23
33
|
}
|
|
24
34
|
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
// SetDeregistrationDrep saves a deregistration drep certificate
|
|
36
|
+
func (d *Database) SetDeregistrationDrep(
|
|
37
|
+
cert *lcommon.DeregistrationDrepCertificate,
|
|
38
|
+
slot, deposit uint64,
|
|
39
|
+
txn *Txn,
|
|
40
|
+
) error {
|
|
41
|
+
return d.metadata.SetDeregistrationDrep(
|
|
42
|
+
cert,
|
|
43
|
+
slot,
|
|
44
|
+
deposit,
|
|
45
|
+
txn.Metadata(),
|
|
46
|
+
)
|
|
27
47
|
}
|
|
@@ -100,33 +100,6 @@ func (d *MetadataStoreSqlite) SetDeregistration(
|
|
|
100
100
|
return nil
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
// SetStakeRegistration saves a stake registration certificate and account
|
|
104
|
-
func (d *MetadataStoreSqlite) SetStakeRegistration(
|
|
105
|
-
cert *lcommon.StakeRegistrationCertificate,
|
|
106
|
-
slot, deposit uint64,
|
|
107
|
-
txn *gorm.DB,
|
|
108
|
-
) error {
|
|
109
|
-
stakeKey := cert.StakeRegistration.Credential.Bytes()
|
|
110
|
-
tmpItem := models.StakeRegistration{
|
|
111
|
-
StakingKey: stakeKey,
|
|
112
|
-
AddedSlot: slot,
|
|
113
|
-
DepositAmount: deposit,
|
|
114
|
-
}
|
|
115
|
-
if err := d.SetAccount(stakeKey, nil, nil, slot, true, txn); err != nil {
|
|
116
|
-
return err
|
|
117
|
-
}
|
|
118
|
-
if txn != nil {
|
|
119
|
-
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
120
|
-
return result.Error
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
124
|
-
return result.Error
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return nil
|
|
128
|
-
}
|
|
129
|
-
|
|
130
103
|
// SetRegistration saves a registration certificate and account
|
|
131
104
|
func (d *MetadataStoreSqlite) SetRegistration(
|
|
132
105
|
cert *lcommon.RegistrationCertificate,
|
|
@@ -222,3 +195,119 @@ func (d *MetadataStoreSqlite) SetStakeDeregistration(
|
|
|
222
195
|
}
|
|
223
196
|
return nil
|
|
224
197
|
}
|
|
198
|
+
|
|
199
|
+
// SetStakeRegistration saves a stake registration certificate and account
|
|
200
|
+
func (d *MetadataStoreSqlite) SetStakeRegistration(
|
|
201
|
+
cert *lcommon.StakeRegistrationCertificate,
|
|
202
|
+
slot, deposit uint64,
|
|
203
|
+
txn *gorm.DB,
|
|
204
|
+
) error {
|
|
205
|
+
stakeKey := cert.StakeRegistration.Credential.Bytes()
|
|
206
|
+
tmpItem := models.StakeRegistration{
|
|
207
|
+
StakingKey: stakeKey,
|
|
208
|
+
AddedSlot: slot,
|
|
209
|
+
DepositAmount: deposit,
|
|
210
|
+
}
|
|
211
|
+
if err := d.SetAccount(stakeKey, nil, nil, slot, true, txn); err != nil {
|
|
212
|
+
return err
|
|
213
|
+
}
|
|
214
|
+
if txn != nil {
|
|
215
|
+
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
216
|
+
return result.Error
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
220
|
+
return result.Error
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return nil
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// SetStakeRegistrationDelegation saves a stake registration delegation certificate and account
|
|
227
|
+
func (d *MetadataStoreSqlite) SetStakeRegistrationDelegation(
|
|
228
|
+
cert *lcommon.StakeRegistrationDelegationCertificate,
|
|
229
|
+
slot, deposit uint64,
|
|
230
|
+
txn *gorm.DB,
|
|
231
|
+
) error {
|
|
232
|
+
stakeKey := cert.StakeCredential.Credential.Bytes()
|
|
233
|
+
pkh := cert.PoolKeyHash[:]
|
|
234
|
+
tmpItem := models.StakeRegistrationDelegation{
|
|
235
|
+
StakingKey: stakeKey,
|
|
236
|
+
PoolKeyHash: pkh,
|
|
237
|
+
AddedSlot: slot,
|
|
238
|
+
DepositAmount: deposit,
|
|
239
|
+
}
|
|
240
|
+
if err := d.SetAccount(stakeKey, pkh, nil, slot, true, txn); err != nil {
|
|
241
|
+
return err
|
|
242
|
+
}
|
|
243
|
+
if txn != nil {
|
|
244
|
+
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
245
|
+
return result.Error
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
249
|
+
return result.Error
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return nil
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// SetStakeVoteRegistrationDelegation saves a stake vote registration delegation certificate and account
|
|
256
|
+
func (d *MetadataStoreSqlite) SetStakeVoteRegistrationDelegation(
|
|
257
|
+
cert *lcommon.StakeVoteRegistrationDelegationCertificate,
|
|
258
|
+
slot, deposit uint64,
|
|
259
|
+
txn *gorm.DB,
|
|
260
|
+
) error {
|
|
261
|
+
stakeKey := cert.StakeCredential.Credential.Bytes()
|
|
262
|
+
pkh := cert.PoolKeyHash[:]
|
|
263
|
+
drep := cert.Drep.Credential[:]
|
|
264
|
+
tmpItem := models.StakeVoteRegistrationDelegation{
|
|
265
|
+
StakingKey: stakeKey,
|
|
266
|
+
PoolKeyHash: pkh,
|
|
267
|
+
Drep: drep,
|
|
268
|
+
AddedSlot: slot,
|
|
269
|
+
DepositAmount: deposit,
|
|
270
|
+
}
|
|
271
|
+
if err := d.SetAccount(stakeKey, pkh, drep, slot, true, txn); err != nil {
|
|
272
|
+
return err
|
|
273
|
+
}
|
|
274
|
+
if txn != nil {
|
|
275
|
+
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
276
|
+
return result.Error
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
280
|
+
return result.Error
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return nil
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// SetVoteRegistrationDelegation saves a vote registration delegation certificate and account
|
|
287
|
+
func (d *MetadataStoreSqlite) SetVoteRegistrationDelegation(
|
|
288
|
+
cert *lcommon.VoteRegistrationDelegationCertificate,
|
|
289
|
+
slot, deposit uint64,
|
|
290
|
+
txn *gorm.DB,
|
|
291
|
+
) error {
|
|
292
|
+
stakeKey := cert.StakeCredential.Credential.Bytes()
|
|
293
|
+
drep := cert.Drep.Credential[:]
|
|
294
|
+
tmpItem := models.VoteRegistrationDelegation{
|
|
295
|
+
StakingKey: stakeKey,
|
|
296
|
+
Drep: drep,
|
|
297
|
+
AddedSlot: slot,
|
|
298
|
+
DepositAmount: deposit,
|
|
299
|
+
}
|
|
300
|
+
if err := d.SetAccount(stakeKey, nil, drep, slot, true, txn); err != nil {
|
|
301
|
+
return err
|
|
302
|
+
}
|
|
303
|
+
if txn != nil {
|
|
304
|
+
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
305
|
+
return result.Error
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
309
|
+
return result.Error
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return nil
|
|
313
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
|
|
20
|
+
"gorm.io/gorm"
|
|
21
|
+
"gorm.io/gorm/clause"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// GetDrep gets a drep
|
|
25
|
+
func (d *MetadataStoreSqlite) GetDrep(
|
|
26
|
+
cred []byte,
|
|
27
|
+
txn *gorm.DB,
|
|
28
|
+
) (models.Drep, error) {
|
|
29
|
+
ret := models.Drep{}
|
|
30
|
+
tmpDrep := models.Drep{}
|
|
31
|
+
if txn != nil {
|
|
32
|
+
if result := txn.First(&tmpDrep, "credential = ?", cred); result.Error != nil {
|
|
33
|
+
return ret, result.Error
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
if result := d.DB().First(&tmpDrep, "credential = ?", cred); result.Error != nil {
|
|
37
|
+
return ret, result.Error
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
ret = tmpDrep
|
|
41
|
+
return ret, nil
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// SetDrep saves a drep
|
|
45
|
+
func (d *MetadataStoreSqlite) SetDrep(
|
|
46
|
+
cred []byte,
|
|
47
|
+
slot uint64,
|
|
48
|
+
url string,
|
|
49
|
+
hash []byte,
|
|
50
|
+
active bool,
|
|
51
|
+
txn *gorm.DB,
|
|
52
|
+
) error {
|
|
53
|
+
tmpItem := models.Drep{
|
|
54
|
+
Credential: cred,
|
|
55
|
+
AddedSlot: slot,
|
|
56
|
+
AnchorUrl: url,
|
|
57
|
+
AnchorHash: hash,
|
|
58
|
+
Active: active,
|
|
59
|
+
}
|
|
60
|
+
if txn != nil {
|
|
61
|
+
if result := txn.Clauses(clause.OnConflict{UpdateAll: true}).Create(&tmpItem); result.Error != nil {
|
|
62
|
+
return result.Error
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
if result := d.DB().Clauses(clause.OnConflict{UpdateAll: true}).Create(&tmpItem); result.Error != nil {
|
|
66
|
+
return result.Error
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return nil
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// SetDeregistrationDrep saves a deregistration drep certificate and drep
|
|
73
|
+
func (d *MetadataStoreSqlite) SetDeregistrationDrep(
|
|
74
|
+
cert *lcommon.DeregistrationDrepCertificate,
|
|
75
|
+
slot, deposit uint64,
|
|
76
|
+
txn *gorm.DB,
|
|
77
|
+
) error {
|
|
78
|
+
drep := cert.DrepCredential.Credential.Bytes()
|
|
79
|
+
tmpDrep, err := d.GetDrep(drep, txn)
|
|
80
|
+
if err != nil {
|
|
81
|
+
return err
|
|
82
|
+
}
|
|
83
|
+
tmpItem := models.DeregistrationDrep{
|
|
84
|
+
DrepCredential: drep,
|
|
85
|
+
AddedSlot: slot,
|
|
86
|
+
DepositAmount: deposit,
|
|
87
|
+
}
|
|
88
|
+
tmpDrep.Active = false
|
|
89
|
+
if txn != nil {
|
|
90
|
+
if drepErr := txn.Save(&tmpDrep); drepErr.Error != nil {
|
|
91
|
+
return drepErr.Error
|
|
92
|
+
}
|
|
93
|
+
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
94
|
+
return result.Error
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
if drepErr := d.DB().Save(&tmpDrep); drepErr.Error != nil {
|
|
98
|
+
return drepErr.Error
|
|
99
|
+
}
|
|
100
|
+
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
101
|
+
return result.Error
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return nil
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// SetRegistrationDrep saves a registration drep certificate and drep
|
|
108
|
+
func (d *MetadataStoreSqlite) SetRegistrationDrep(
|
|
109
|
+
cert *lcommon.RegistrationDrepCertificate,
|
|
110
|
+
slot, deposit uint64,
|
|
111
|
+
txn *gorm.DB,
|
|
112
|
+
) error {
|
|
113
|
+
drep := cert.DrepCredential.Credential.Bytes()
|
|
114
|
+
tmpItem := models.RegistrationDrep{
|
|
115
|
+
DrepCredential: drep,
|
|
116
|
+
AddedSlot: slot,
|
|
117
|
+
DepositAmount: deposit,
|
|
118
|
+
}
|
|
119
|
+
var anchorUrl string
|
|
120
|
+
var anchorHash []byte
|
|
121
|
+
if cert.Anchor != nil {
|
|
122
|
+
anchorUrl = cert.Anchor.Url
|
|
123
|
+
anchorHash = cert.Anchor.DataHash[:]
|
|
124
|
+
}
|
|
125
|
+
tmpItem.AnchorUrl = anchorUrl
|
|
126
|
+
tmpItem.AnchorHash = anchorHash
|
|
127
|
+
if err := d.SetDrep(drep, slot, anchorUrl, anchorHash, true, txn); err != nil {
|
|
128
|
+
return err
|
|
129
|
+
}
|
|
130
|
+
if txn != nil {
|
|
131
|
+
if result := txn.Create(&tmpItem); result.Error != nil {
|
|
132
|
+
return result.Error
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
if result := d.DB().Create(&tmpItem); result.Error != nil {
|
|
136
|
+
return result.Error
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return nil
|
|
140
|
+
}
|
|
@@ -79,3 +79,40 @@ type StakeRegistration struct {
|
|
|
79
79
|
func (StakeRegistration) TableName() string {
|
|
80
80
|
return "stake_registration"
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
type StakeRegistrationDelegation struct {
|
|
84
|
+
ID uint `gorm:"primarykey"`
|
|
85
|
+
StakingKey []byte `gorm:"index"`
|
|
86
|
+
PoolKeyHash []byte `gorm:"index"`
|
|
87
|
+
AddedSlot uint64
|
|
88
|
+
DepositAmount uint64
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
func (StakeRegistrationDelegation) TableName() string {
|
|
92
|
+
return "stake_registration_delegation"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type StakeVoteRegistrationDelegation struct {
|
|
96
|
+
ID uint `gorm:"primarykey"`
|
|
97
|
+
StakingKey []byte `gorm:"index"`
|
|
98
|
+
PoolKeyHash []byte `gorm:"index"`
|
|
99
|
+
Drep []byte `gorm:"index"`
|
|
100
|
+
AddedSlot uint64
|
|
101
|
+
DepositAmount uint64
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
func (StakeVoteRegistrationDelegation) TableName() string {
|
|
105
|
+
return "stake_vote_registration_delegation"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type VoteRegistrationDelegation struct {
|
|
109
|
+
ID uint `gorm:"primarykey"`
|
|
110
|
+
StakingKey []byte `gorm:"index"`
|
|
111
|
+
Drep []byte `gorm:"index"`
|
|
112
|
+
AddedSlot uint64
|
|
113
|
+
DepositAmount uint64
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
func (VoteRegistrationDelegation) TableName() string {
|
|
117
|
+
return "vote_registration_delegation"
|
|
118
|
+
}
|
|
@@ -20,8 +20,33 @@ type Drep struct {
|
|
|
20
20
|
AnchorUrl string
|
|
21
21
|
AnchorHash []byte
|
|
22
22
|
AddedSlot uint64
|
|
23
|
+
Active bool `gorm:"default:true"`
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
func (d *Drep) TableName() string {
|
|
26
27
|
return "drep"
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
type DeregistrationDrep struct {
|
|
31
|
+
ID uint `gorm:"primarykey"`
|
|
32
|
+
DrepCredential []byte `gorm:"index"`
|
|
33
|
+
AddedSlot uint64
|
|
34
|
+
DepositAmount uint64
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func (DeregistrationDrep) TableName() string {
|
|
38
|
+
return "deregistration_drep"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type RegistrationDrep struct {
|
|
42
|
+
ID uint `gorm:"primarykey"`
|
|
43
|
+
DrepCredential []byte `gorm:"index"`
|
|
44
|
+
AddedSlot uint64
|
|
45
|
+
DepositAmount uint64
|
|
46
|
+
AnchorUrl string
|
|
47
|
+
AnchorHash []byte
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
func (RegistrationDrep) TableName() string {
|
|
51
|
+
return "registration_drep"
|
|
52
|
+
}
|
|
@@ -13,14 +13,3 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
15
|
package models
|
|
16
|
-
|
|
17
|
-
type VoteRegistrationDelegation struct {
|
|
18
|
-
ID uint `gorm:"primarykey"`
|
|
19
|
-
StakingKey []byte `gorm:"index"`
|
|
20
|
-
Drep []byte `gorm:"index"`
|
|
21
|
-
AddedSlot uint64
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
func (VoteRegistrationDelegation) TableName() string {
|
|
25
|
-
return "vote_registration_delegation"
|
|
26
|
-
}
|
|
@@ -75,6 +75,12 @@ type MetadataStore interface {
|
|
|
75
75
|
uint64, // slot
|
|
76
76
|
*gorm.DB,
|
|
77
77
|
) error
|
|
78
|
+
SetDeregistrationDrep(
|
|
79
|
+
*lcommon.DeregistrationDrepCertificate,
|
|
80
|
+
uint64, // slot
|
|
81
|
+
uint64, // deposit
|
|
82
|
+
*gorm.DB,
|
|
83
|
+
) error
|
|
78
84
|
SetEpoch(
|
|
79
85
|
uint64, // slot
|
|
80
86
|
uint64, // epoch
|
|
@@ -115,6 +121,12 @@ type MetadataStore interface {
|
|
|
115
121
|
uint64, // deposit
|
|
116
122
|
*gorm.DB,
|
|
117
123
|
) error
|
|
124
|
+
SetRegistrationDrep(
|
|
125
|
+
*lcommon.RegistrationDrepCertificate,
|
|
126
|
+
uint64, // slot
|
|
127
|
+
uint64, // deposit
|
|
128
|
+
*gorm.DB,
|
|
129
|
+
) error
|
|
118
130
|
SetStakeDelegation(
|
|
119
131
|
*lcommon.StakeDelegationCertificate,
|
|
120
132
|
uint64, // slot
|
|
@@ -131,6 +143,18 @@ type MetadataStore interface {
|
|
|
131
143
|
uint64, // deposit
|
|
132
144
|
*gorm.DB,
|
|
133
145
|
) error
|
|
146
|
+
SetStakeRegistrationDelegation(
|
|
147
|
+
*lcommon.StakeRegistrationDelegationCertificate,
|
|
148
|
+
uint64, // slot
|
|
149
|
+
uint64, // deposit
|
|
150
|
+
*gorm.DB,
|
|
151
|
+
) error
|
|
152
|
+
SetStakeVoteRegistrationDelegation(
|
|
153
|
+
*lcommon.StakeVoteRegistrationDelegationCertificate,
|
|
154
|
+
uint64, // slot
|
|
155
|
+
uint64, // deposit
|
|
156
|
+
*gorm.DB,
|
|
157
|
+
) error
|
|
134
158
|
SetTip(
|
|
135
159
|
ochainsync.Tip,
|
|
136
160
|
*gorm.DB,
|
|
@@ -143,6 +167,12 @@ type MetadataStore interface {
|
|
|
143
167
|
[]byte, // stake
|
|
144
168
|
*gorm.DB,
|
|
145
169
|
) error
|
|
170
|
+
SetVoteRegistrationDelegation(
|
|
171
|
+
*lcommon.VoteRegistrationDelegationCertificate,
|
|
172
|
+
uint64, // slot
|
|
173
|
+
uint64, // deposit
|
|
174
|
+
*gorm.DB,
|
|
175
|
+
) error
|
|
146
176
|
|
|
147
177
|
// Helpers
|
|
148
178
|
DeleteUtxo(any, *gorm.DB) error
|
package/go.mod
CHANGED
|
@@ -8,7 +8,7 @@ require (
|
|
|
8
8
|
connectrpc.com/connect v1.18.1
|
|
9
9
|
connectrpc.com/grpchealth v1.4.0
|
|
10
10
|
connectrpc.com/grpcreflect v1.3.0
|
|
11
|
-
github.com/blinklabs-io/gouroboros v0.
|
|
11
|
+
github.com/blinklabs-io/gouroboros v0.120.0
|
|
12
12
|
github.com/blinklabs-io/ouroboros-mock v0.3.7
|
|
13
13
|
github.com/dgraph-io/badger/v4 v4.7.0
|
|
14
14
|
github.com/glebarez/sqlite v1.11.0
|
package/go.sum
CHANGED
|
@@ -15,8 +15,8 @@ github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1
|
|
|
15
15
|
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
|
|
16
16
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
|
17
17
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
|
18
|
-
github.com/blinklabs-io/gouroboros v0.
|
|
19
|
-
github.com/blinklabs-io/gouroboros v0.
|
|
18
|
+
github.com/blinklabs-io/gouroboros v0.120.0 h1:k51DBcycE0I4D4IrW5BW7JFvQZNUNYcoIUwmM5KthTQ=
|
|
19
|
+
github.com/blinklabs-io/gouroboros v0.120.0/go.mod h1:4slb9HmHNlV1Z7wi6WDDa9GlYCutff8qCEfGYRVN9i8=
|
|
20
20
|
github.com/blinklabs-io/ouroboros-mock v0.3.7 h1:86FvD591XhdGk2BqQweRKfwc6Y6ll5Lunmo/RUehJ6o=
|
|
21
21
|
github.com/blinklabs-io/ouroboros-mock v0.3.7/go.mod h1:611xZgdWCxZsSaS5tjgxqjmWIkSpsM9eKuQAKozw+sk=
|
|
22
22
|
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
package/ledger/certs.go
CHANGED
|
@@ -18,6 +18,7 @@ import (
|
|
|
18
18
|
"fmt"
|
|
19
19
|
|
|
20
20
|
"github.com/blinklabs-io/dingo/database"
|
|
21
|
+
"github.com/blinklabs-io/gouroboros/ledger"
|
|
21
22
|
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
|
|
22
23
|
pcommon "github.com/blinklabs-io/gouroboros/protocol/common"
|
|
23
24
|
)
|
|
@@ -25,10 +26,10 @@ import (
|
|
|
25
26
|
func (ls *LedgerState) processTransactionCertificates(
|
|
26
27
|
txn *database.Txn,
|
|
27
28
|
blockPoint pcommon.Point,
|
|
28
|
-
|
|
29
|
+
certs []ledger.Certificate,
|
|
29
30
|
) error {
|
|
30
31
|
var tmpCert lcommon.Certificate
|
|
31
|
-
for _, tmpCert = range
|
|
32
|
+
for _, tmpCert = range certs {
|
|
32
33
|
certDeposit, err := ls.currentEra.CertDepositFunc(
|
|
33
34
|
tmpCert,
|
|
34
35
|
ls.currentPParams,
|
|
@@ -46,6 +47,16 @@ func (ls *LedgerState) processTransactionCertificates(
|
|
|
46
47
|
if err != nil {
|
|
47
48
|
return err
|
|
48
49
|
}
|
|
50
|
+
case *lcommon.DeregistrationDrepCertificate:
|
|
51
|
+
err := ls.db.SetDeregistrationDrep(
|
|
52
|
+
cert,
|
|
53
|
+
blockPoint.Slot,
|
|
54
|
+
certDeposit,
|
|
55
|
+
txn,
|
|
56
|
+
)
|
|
57
|
+
if err != nil {
|
|
58
|
+
return err
|
|
59
|
+
}
|
|
49
60
|
case *lcommon.PoolRegistrationCertificate:
|
|
50
61
|
err := ls.db.SetPoolRegistration(
|
|
51
62
|
cert,
|
|
@@ -75,6 +86,16 @@ func (ls *LedgerState) processTransactionCertificates(
|
|
|
75
86
|
if err != nil {
|
|
76
87
|
return err
|
|
77
88
|
}
|
|
89
|
+
case *lcommon.RegistrationDrepCertificate:
|
|
90
|
+
err := ls.db.SetRegistrationDrep(
|
|
91
|
+
cert,
|
|
92
|
+
blockPoint.Slot,
|
|
93
|
+
certDeposit,
|
|
94
|
+
txn,
|
|
95
|
+
)
|
|
96
|
+
if err != nil {
|
|
97
|
+
return err
|
|
98
|
+
}
|
|
78
99
|
case *lcommon.StakeDelegationCertificate:
|
|
79
100
|
err := ls.db.SetStakeDelegation(
|
|
80
101
|
cert,
|
|
@@ -103,6 +124,36 @@ func (ls *LedgerState) processTransactionCertificates(
|
|
|
103
124
|
if err != nil {
|
|
104
125
|
return err
|
|
105
126
|
}
|
|
127
|
+
case *lcommon.StakeRegistrationDelegationCertificate:
|
|
128
|
+
err := ls.db.SetStakeRegistrationDelegation(
|
|
129
|
+
cert,
|
|
130
|
+
blockPoint.Slot,
|
|
131
|
+
certDeposit,
|
|
132
|
+
txn,
|
|
133
|
+
)
|
|
134
|
+
if err != nil {
|
|
135
|
+
return err
|
|
136
|
+
}
|
|
137
|
+
case *lcommon.StakeVoteRegistrationDelegationCertificate:
|
|
138
|
+
err := ls.db.SetStakeVoteRegistrationDelegation(
|
|
139
|
+
cert,
|
|
140
|
+
blockPoint.Slot,
|
|
141
|
+
certDeposit,
|
|
142
|
+
txn,
|
|
143
|
+
)
|
|
144
|
+
if err != nil {
|
|
145
|
+
return err
|
|
146
|
+
}
|
|
147
|
+
case *lcommon.VoteRegistrationDelegationCertificate:
|
|
148
|
+
err := ls.db.SetVoteRegistrationDelegation(
|
|
149
|
+
cert,
|
|
150
|
+
blockPoint.Slot,
|
|
151
|
+
certDeposit,
|
|
152
|
+
txn,
|
|
153
|
+
)
|
|
154
|
+
if err != nil {
|
|
155
|
+
return err
|
|
156
|
+
}
|
|
106
157
|
default:
|
|
107
158
|
ls.config.Logger.Warn(
|
|
108
159
|
fmt.Sprintf("ignoring unsupported certificate type %T", cert),
|