Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: filter transactions for pool (de)registrations #210

Merged
merged 1 commit into from
May 16, 2024
Merged
Changes from all commits
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
49 changes: 47 additions & 2 deletions filter/chainsync/chainsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,8 @@ func (c *ChainSync) Start() error {
isPoolBech32 := strings.HasPrefix(filterPoolId, "pool")
foundMatch := false
for _, certificate := range v.Certificates {
switch certificate.(type) {
switch cert := certificate.(type) {
case *ledger.StakeDelegationCertificate:
wolf31o2 marked this conversation as resolved.
Show resolved Hide resolved
cert := &ledger.StakeDelegationCertificate{}
b := &ledger.Blake2b224{}
copy(b[:], cert.PoolKeyHash[:])
if b.String() == filterPoolId {
Expand All @@ -229,6 +228,52 @@ func (c *ChainSync) Start() error {
filterMatched = true
break
}
case *ledger.PoolRetirementCertificate:
b := &ledger.Blake2b224{}
copy(b[:], cert.PoolKeyHash[:])
if b.String() == filterPoolId {
foundMatch = true
} else if isPoolBech32 {
// lifted from gouroboros/ledger
convData, err := bech32.ConvertBits(certificate.Cbor(), 8, 5, true)
if err != nil {
continue
}
encoded, err := bech32.Encode("pool", convData)
if err != nil {
continue
}
if encoded == filterPoolId {
foundMatch = true
}
}
if foundMatch {
filterMatched = true
break
}
case *ledger.PoolRegistrationCertificate:
b := &ledger.Blake2b224{}
copy(b[:], cert.Operator[:])
if b.String() == filterPoolId {
foundMatch = true
} else if isPoolBech32 {
// lifted from gouroboros/ledger
convData, err := bech32.ConvertBits(certificate.Cbor(), 8, 5, true)
if err != nil {
continue
}
encoded, err := bech32.Encode("pool", convData)
if err != nil {
continue
}
if encoded == filterPoolId {
foundMatch = true
}
}
if foundMatch {
filterMatched = true
break
}
}
}
if foundMatch {
Expand Down