Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions internal/test/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,15 @@ func (ls MockLedgerState) StakeRegistration(
return ret, nil
}

func (ls MockLedgerState) PoolRegistration(
func (ls MockLedgerState) PoolCurrentState(
poolKeyHash []byte,
) ([]common.PoolRegistrationCertificate, error) {
ret := []common.PoolRegistrationCertificate{}
) (*common.PoolRegistrationCertificate, *uint64, error) {
for _, cert := range ls.MockPoolRegistration {
if string(
common.Blake2b224(cert.Operator).Bytes(),
) == string(
poolKeyHash,
) {
ret = append(ret, cert)
if string(common.Blake2b224(cert.Operator).Bytes()) == string(poolKeyHash) {
// pretend latest registration is current; no retirement support in mock
c := cert
return &c, nil, nil
}
}
return ret, nil
return nil, nil, nil
}
4 changes: 2 additions & 2 deletions ledger/alonzo/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ func UtxoValidateValueNotConservedUtxo(
for _, cert := range tx.Certificates() {
switch tmpCert := cert.(type) {
case *common.PoolRegistrationCertificate:
certs, err := ls.PoolRegistration(common.Blake2b224(tmpCert.Operator).Bytes())
reg, _, err := ls.PoolCurrentState(common.Blake2b224(tmpCert.Operator).Bytes())
if err != nil {
return err
}
if len(certs) == 0 {
if reg == nil {
producedValue += uint64(tmpPparams.PoolDeposit)
}
case *common.StakeRegistrationCertificate:
Expand Down
4 changes: 2 additions & 2 deletions ledger/babbage/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ func UtxoValidateValueNotConservedUtxo(
for _, cert := range tx.Certificates() {
switch tmpCert := cert.(type) {
case *common.PoolRegistrationCertificate:
certs, err := ls.PoolRegistration(common.Blake2b224(tmpCert.Operator).Bytes())
reg, _, err := ls.PoolCurrentState(common.Blake2b224(tmpCert.Operator).Bytes())
if err != nil {
return err
}
if len(certs) == 0 {
if reg == nil {
producedValue += uint64(tmpPparams.PoolDeposit)
}
case *common.StakeRegistrationCertificate:
Expand Down
7 changes: 6 additions & 1 deletion ledger/common/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ type UtxoState interface {
// CertState defines the interface for querying the certificate state
type CertState interface {
StakeRegistration([]byte) ([]StakeRegistrationCertificate, error)
PoolRegistration([]byte) ([]PoolRegistrationCertificate, error)
}

// PoolState defines the interface for querying the current pool state
type PoolState interface {
PoolCurrentState([]byte) (*PoolRegistrationCertificate, *uint64, error)
}

// LedgerState defines the interface for querying the ledger
type LedgerState interface {
UtxoState
CertState
PoolState
NetworkId() uint
}

Expand Down
4 changes: 2 additions & 2 deletions ledger/conway/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ func UtxoValidateValueNotConservedUtxo(
for _, cert := range tx.Certificates() {
switch tmpCert := cert.(type) {
case *common.PoolRegistrationCertificate:
certs, err := ls.PoolRegistration(common.Blake2b224(tmpCert.Operator).Bytes())
reg, _, err := ls.PoolCurrentState(common.Blake2b224(tmpCert.Operator).Bytes())
if err != nil {
return err
}
if len(certs) == 0 {
if reg == nil {
producedValue += uint64(tmpPparams.PoolDeposit)
}
case *common.RegistrationCertificate:
Expand Down
4 changes: 2 additions & 2 deletions ledger/shelley/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ func UtxoValidateValueNotConservedUtxo(
for _, cert := range tx.Certificates() {
switch tmpCert := cert.(type) {
case *common.PoolRegistrationCertificate:
certs, err := ls.PoolRegistration(common.Blake2b224(tmpCert.Operator).Bytes())
reg, _, err := ls.PoolCurrentState(common.Blake2b224(tmpCert.Operator).Bytes())
if err != nil {
return err
}
if len(certs) == 0 {
if reg == nil {
producedValue += uint64(tmpPparams.PoolDeposit)
}
case *common.StakeRegistrationCertificate:
Expand Down