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(
6363 return ret , nil
6464}
6565
66- func (ls MockLedgerState ) PoolRegistration (
66+ func (ls MockLedgerState ) PoolCurrentState (
6767 poolKeyHash []byte ,
68- ) ([]common.PoolRegistrationCertificate , error ) {
69- ret := []common.PoolRegistrationCertificate {}
68+ ) (* common.PoolRegistrationCertificate , * uint64 , error ) {
7069 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
7774 }
7875 }
79- return ret , nil
76+ return nil , nil , nil
8077}
8178
8279func (ls MockLedgerState ) SlotToTime (slot uint64 ) (time.Time , error ) {
Original file line number Diff line number Diff line change @@ -289,11 +289,11 @@ func UtxoValidateValueNotConservedUtxo(
289289 for _ , cert := range tx .Certificates () {
290290 switch tmpCert := cert .(type ) {
291291 case * common.PoolRegistrationCertificate :
292- certs , err := ls .PoolRegistration (common .Blake2b224 (tmpCert .Operator ).Bytes ())
292+ reg , _ , err := ls .PoolCurrentState (common .Blake2b224 (tmpCert .Operator ).Bytes ())
293293 if err != nil {
294294 return err
295295 }
296- if len ( certs ) == 0 {
296+ if reg == nil {
297297 producedValue += uint64 (tmpPparams .PoolDeposit )
298298 }
299299 case * common.StakeRegistrationCertificate :
Original file line number Diff line number Diff line change @@ -275,11 +275,11 @@ func UtxoValidateValueNotConservedUtxo(
275275 for _ , cert := range tx .Certificates () {
276276 switch tmpCert := cert .(type ) {
277277 case * common.PoolRegistrationCertificate :
278- certs , err := ls .PoolRegistration (common .Blake2b224 (tmpCert .Operator ).Bytes ())
278+ reg , _ , err := ls .PoolCurrentState (common .Blake2b224 (tmpCert .Operator ).Bytes ())
279279 if err != nil {
280280 return err
281281 }
282- if len ( certs ) == 0 {
282+ if reg == nil {
283283 producedValue += uint64 (tmpPparams .PoolDeposit )
284284 }
285285 case * common.StakeRegistrationCertificate :
Original file line number Diff line number Diff line change @@ -28,14 +28,22 @@ type UtxoState interface {
2828// CertState defines the interface for querying the certificate state
2929type CertState interface {
3030 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 )
3239}
3340
3441// LedgerState defines the interface for querying the ledger
3542type LedgerState interface {
3643 UtxoState
3744 CertState
3845 SlotState
46+ PoolState
3947 NetworkId () uint
4048}
4149
Original file line number Diff line number Diff line change @@ -272,11 +272,11 @@ func UtxoValidateValueNotConservedUtxo(
272272 for _ , cert := range tx .Certificates () {
273273 switch tmpCert := cert .(type ) {
274274 case * common.PoolRegistrationCertificate :
275- certs , err := ls .PoolRegistration (common .Blake2b224 (tmpCert .Operator ).Bytes ())
275+ reg , _ , err := ls .PoolCurrentState (common .Blake2b224 (tmpCert .Operator ).Bytes ())
276276 if err != nil {
277277 return err
278278 }
279- if len ( certs ) == 0 {
279+ if reg == nil {
280280 producedValue += uint64 (tmpPparams .PoolDeposit )
281281 }
282282 case * common.RegistrationCertificate :
Original file line number Diff line number Diff line change @@ -196,11 +196,11 @@ func UtxoValidateValueNotConservedUtxo(
196196 for _ , cert := range tx .Certificates () {
197197 switch tmpCert := cert .(type ) {
198198 case * common.PoolRegistrationCertificate :
199- certs , err := ls .PoolRegistration (common .Blake2b224 (tmpCert .Operator ).Bytes ())
199+ reg , _ , err := ls .PoolCurrentState (common .Blake2b224 (tmpCert .Operator ).Bytes ())
200200 if err != nil {
201201 return err
202202 }
203- if len ( certs ) == 0 {
203+ if reg == nil {
204204 producedValue += uint64 (tmpPparams .PoolDeposit )
205205 }
206206 case * common.StakeRegistrationCertificate :
You can’t perform that action at this time.
0 commit comments