Commit f1fa3b44 authored by acud's avatar acud Committed by GitHub

fix: duplicate issuers (#2128)

parent c3c87289
...@@ -78,6 +78,12 @@ func NewService(store storage.StateStorer, postageStore Storer, chainID int64) ( ...@@ -78,6 +78,12 @@ func NewService(store storage.StateStorer, postageStore Storer, chainID int64) (
func (ps *service) Add(st *StampIssuer) { func (ps *service) Add(st *StampIssuer) {
ps.lock.Lock() ps.lock.Lock()
defer ps.lock.Unlock() defer ps.lock.Unlock()
for _, v := range ps.issuers {
if bytes.Equal(st.data.BatchID, v.data.BatchID) {
return
}
}
ps.issuers = append(ps.issuers, st) ps.issuers = append(ps.issuers, st)
} }
...@@ -85,8 +91,6 @@ func (ps *service) Add(st *StampIssuer) { ...@@ -85,8 +91,6 @@ func (ps *service) Add(st *StampIssuer) {
// a batch creation event from the blockchain listener to ensure that if a stamp // a batch creation event from the blockchain listener to ensure that if a stamp
// issuer was not created initially, we will create it here. // issuer was not created initially, we will create it here.
func (ps *service) Handle(b *Batch) { func (ps *service) Handle(b *Batch) {
_, err := ps.GetStampIssuer(b.ID)
if errors.Is(err, ErrNotFound) {
ps.Add(NewStampIssuer( ps.Add(NewStampIssuer(
"recovered", "recovered",
string(b.Owner), string(b.Owner),
...@@ -97,7 +101,6 @@ func (ps *service) Handle(b *Batch) { ...@@ -97,7 +101,6 @@ func (ps *service) Handle(b *Batch) {
b.Start, b.Start,
b.Immutable, b.Immutable,
)) ))
}
} }
// StampIssuers returns the currently active stamp issuers. // StampIssuers returns the currently active stamp issuers.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment