File tree Expand file tree Collapse file tree 6 files changed +24
-19
lines changed Expand file tree Collapse file tree 6 files changed +24
-19
lines changed Original file line number Diff line number Diff line change @@ -63,20 +63,17 @@ func (ls MockLedgerState) StakeRegistration(
63
63
return ret , nil
64
64
}
65
65
66
- func (ls MockLedgerState ) PoolRegistration (
66
+ func (ls MockLedgerState ) PoolCurrentState (
67
67
poolKeyHash []byte ,
68
- ) ([]common.PoolRegistrationCertificate , error ) {
69
- ret := []common.PoolRegistrationCertificate {}
68
+ ) (* common.PoolRegistrationCertificate , * uint64 , error ) {
70
69
for _ , cert := range ls .MockPoolRegistration {
71
- if string (
72
- common .Blake2b224 (cert .Operator ).Bytes (),
73
- ) == string (
74
- poolKeyHash ,
75
- ) {
76
- ret = append (ret , cert )
70
+ if string (common .Blake2b224 (cert .Operator ).Bytes ()) == string (poolKeyHash ) {
71
+ // pretend latest registration is current; no retirement support in mock
72
+ c := cert
73
+ return & c , nil , nil
77
74
}
78
75
}
79
- return ret , nil
76
+ return nil , nil , nil
80
77
}
81
78
82
79
func (ls MockLedgerState ) SlotToTime (slot uint64 ) (time.Time , error ) {
Original file line number Diff line number Diff line change @@ -289,11 +289,11 @@ func UtxoValidateValueNotConservedUtxo(
289
289
for _ , cert := range tx .Certificates () {
290
290
switch tmpCert := cert .(type ) {
291
291
case * common.PoolRegistrationCertificate :
292
- certs , err := ls .PoolRegistration (common .Blake2b224 (tmpCert .Operator ).Bytes ())
292
+ reg , _ , err := ls .PoolCurrentState (common .Blake2b224 (tmpCert .Operator ).Bytes ())
293
293
if err != nil {
294
294
return err
295
295
}
296
- if len ( certs ) == 0 {
296
+ if reg == nil {
297
297
producedValue += uint64 (tmpPparams .PoolDeposit )
298
298
}
299
299
case * common.StakeRegistrationCertificate :
Original file line number Diff line number Diff line change @@ -275,11 +275,11 @@ func UtxoValidateValueNotConservedUtxo(
275
275
for _ , cert := range tx .Certificates () {
276
276
switch tmpCert := cert .(type ) {
277
277
case * common.PoolRegistrationCertificate :
278
- certs , err := ls .PoolRegistration (common .Blake2b224 (tmpCert .Operator ).Bytes ())
278
+ reg , _ , err := ls .PoolCurrentState (common .Blake2b224 (tmpCert .Operator ).Bytes ())
279
279
if err != nil {
280
280
return err
281
281
}
282
- if len ( certs ) == 0 {
282
+ if reg == nil {
283
283
producedValue += uint64 (tmpPparams .PoolDeposit )
284
284
}
285
285
case * common.StakeRegistrationCertificate :
Original file line number Diff line number Diff line change @@ -28,14 +28,22 @@ type UtxoState interface {
28
28
// CertState defines the interface for querying the certificate state
29
29
type CertState interface {
30
30
StakeRegistration ([]byte ) ([]StakeRegistrationCertificate , error )
31
- PoolRegistration ([]byte ) ([]PoolRegistrationCertificate , error )
31
+ }
32
+
33
+ // PoolState defines the interface for querying the current pool state
34
+ type PoolState interface {
35
+ // PoolCurrentState returns the latest active registration certificate for the given pool key hash.
36
+ // It also returns the epoch of a pending retirement certificate, if one exists.
37
+ // If the pool is not registered, the registration certificate will be nil.
38
+ PoolCurrentState ([]byte ) (* PoolRegistrationCertificate , * uint64 , error )
32
39
}
33
40
34
41
// LedgerState defines the interface for querying the ledger
35
42
type LedgerState interface {
36
43
UtxoState
37
44
CertState
38
45
SlotState
46
+ PoolState
39
47
NetworkId () uint
40
48
}
41
49
Original file line number Diff line number Diff line change @@ -272,11 +272,11 @@ func UtxoValidateValueNotConservedUtxo(
272
272
for _ , cert := range tx .Certificates () {
273
273
switch tmpCert := cert .(type ) {
274
274
case * common.PoolRegistrationCertificate :
275
- certs , err := ls .PoolRegistration (common .Blake2b224 (tmpCert .Operator ).Bytes ())
275
+ reg , _ , err := ls .PoolCurrentState (common .Blake2b224 (tmpCert .Operator ).Bytes ())
276
276
if err != nil {
277
277
return err
278
278
}
279
- if len ( certs ) == 0 {
279
+ if reg == nil {
280
280
producedValue += uint64 (tmpPparams .PoolDeposit )
281
281
}
282
282
case * common.RegistrationCertificate :
Original file line number Diff line number Diff line change @@ -196,11 +196,11 @@ func UtxoValidateValueNotConservedUtxo(
196
196
for _ , cert := range tx .Certificates () {
197
197
switch tmpCert := cert .(type ) {
198
198
case * common.PoolRegistrationCertificate :
199
- certs , err := ls .PoolRegistration (common .Blake2b224 (tmpCert .Operator ).Bytes ())
199
+ reg , _ , err := ls .PoolCurrentState (common .Blake2b224 (tmpCert .Operator ).Bytes ())
200
200
if err != nil {
201
201
return err
202
202
}
203
- if len ( certs ) == 0 {
203
+ if reg == nil {
204
204
producedValue += uint64 (tmpPparams .PoolDeposit )
205
205
}
206
206
case * common.StakeRegistrationCertificate :
You can’t perform that action at this time.
0 commit comments