diff --git a/atxsdata/data.go b/atxsdata/data.go index a360d8d45e..e719c85eb2 100644 --- a/atxsdata/data.go +++ b/atxsdata/data.go @@ -5,6 +5,8 @@ import ( "sync" "sync/atomic" + "golang.org/x/exp/maps" + "github.com/spacemeshos/go-spacemesh/common/types" ) @@ -147,6 +149,12 @@ func (d *Data) SetMalicious(node types.NodeID) { d.malicious[node] = struct{}{} } +func (d *Data) MaliciousIdentities() []types.NodeID { + d.mu.RLock() + defer d.mu.RUnlock() + return maps.Keys(d.malicious) +} + // Get returns atx data. // SAFETY: The returned pointer MUST NOT be modified. func (d *Data) Get(epoch types.EpochID, atx types.ATXID) *ATX { diff --git a/tortoise/recover.go b/tortoise/recover.go index 6c742c9fa5..6a150d1318 100644 --- a/tortoise/recover.go +++ b/tortoise/recover.go @@ -13,7 +13,6 @@ import ( "github.com/spacemeshos/go-spacemesh/sql/beacons" "github.com/spacemeshos/go-spacemesh/sql/blocks" "github.com/spacemeshos/go-spacemesh/sql/certificates" - "github.com/spacemeshos/go-spacemesh/sql/identities" "github.com/spacemeshos/go-spacemesh/sql/layers" ) @@ -60,11 +59,7 @@ func Recover( } } - malicious, err := identities.GetMalicious(db) - if err != nil { - return nil, fmt.Errorf("recover malicious %w", err) - } - for _, id := range malicious { + for _, id := range atxdata.MaliciousIdentities() { trtl.OnMalfeasance(id) }