File tree Expand file tree Collapse file tree 5 files changed +62
-1
lines changed
Expand file tree Collapse file tree 5 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,15 @@ func (d *Database) SetPoolRetirement(
5252 return d .metadata .SetPoolRetirement (cert , slot , txn .Metadata ())
5353}
5454
55+ // SetRegistration saves a registration certificate
56+ func (d * Database ) SetRegistration (
57+ cert * lcommon.RegistrationCertificate ,
58+ slot , deposit uint64 ,
59+ txn * Txn ,
60+ ) error {
61+ return d .metadata .SetRegistration (cert , slot , deposit , txn .Metadata ())
62+ }
63+
5564// SetStakeDelegation saves a stake delegation certificate
5665func (d * Database ) SetStakeDelegation (
5766 cert * lcommon.StakeDelegationCertificate ,
Original file line number Diff line number Diff line change @@ -295,3 +295,37 @@ func (d *MetadataStoreSqlite) SetStakeRegistration(
295295 }
296296 return nil
297297}
298+
299+ // SetRegistration saves a registration certificate
300+ func (d * MetadataStoreSqlite ) SetRegistration (
301+ cert * lcommon.RegistrationCertificate ,
302+ slot , deposit uint64 ,
303+ txn * gorm.DB ,
304+ ) error {
305+ tmpAccount := models.Account {
306+ StakingKey : cert .StakeCredential .Credential .Bytes (),
307+ AddedSlot : slot ,
308+ DepositAmount : deposit ,
309+ }
310+ tmpItem := models.Registration {
311+ StakingKey : cert .StakeCredential .Credential .Bytes (),
312+ AddedSlot : slot ,
313+ DepositAmount : deposit ,
314+ }
315+ if txn != nil {
316+ if accountResult := txn .Create (& tmpAccount ); accountResult .Error != nil {
317+ return accountResult .Error
318+ }
319+ if result := txn .Create (& tmpItem ); result .Error != nil {
320+ return result .Error
321+ }
322+ } else {
323+ if accountResult := d .DB ().Create (& tmpAccount ); accountResult .Error != nil {
324+ return accountResult .Error
325+ }
326+ if result := d .DB ().Create (& tmpItem ); result .Error != nil {
327+ return result .Error
328+ }
329+ }
330+ return nil
331+ }
Original file line number Diff line number Diff line change @@ -92,6 +92,12 @@ type MetadataStore interface {
9292 uint64 , // epoch
9393 * gorm.DB ,
9494 ) error
95+ SetRegistration (
96+ * lcommon.RegistrationCertificate ,
97+ uint64 , // slot
98+ uint64 , // deposit
99+ * gorm.DB ,
100+ ) error
95101 SetStakeDelegation (
96102 * lcommon.StakeDelegationCertificate ,
97103 uint64 , // slot
Original file line number Diff line number Diff line change 1- // Copyright 2024 Blink Labs Software
1+ // Copyright 2025 Blink Labs Software
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -56,6 +56,16 @@ func (ls *LedgerState) processTransactionCertificates(
5656 if err != nil {
5757 return err
5858 }
59+ case * lcommon.RegistrationCertificate :
60+ err := ls .db .SetRegistration (
61+ cert ,
62+ blockPoint .Slot ,
63+ certDeposit ,
64+ txn ,
65+ )
66+ if err != nil {
67+ return err
68+ }
5969 case * lcommon.StakeDelegationCertificate :
6070 err := ls .db .SetStakeDelegation (
6171 cert ,
Original file line number Diff line number Diff line change @@ -132,6 +132,8 @@ func CertDepositConway(
132132 switch cert .(type ) {
133133 case * lcommon.PoolRegistrationCertificate :
134134 return uint64 (tmpPparams .PoolDeposit ), nil
135+ case * lcommon.RegistrationCertificate :
136+ return uint64 (tmpPparams .KeyDeposit ), nil
135137 case * lcommon.StakeRegistrationCertificate :
136138 return uint64 (tmpPparams .KeyDeposit ), nil
137139 default :
You can’t perform that action at this time.
0 commit comments