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,19 +91,16 @@ func (ps *service) Add(st *StampIssuer) { ...@@ -85,19 +91,16 @@ 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) ps.Add(NewStampIssuer(
if errors.Is(err, ErrNotFound) { "recovered",
ps.Add(NewStampIssuer( string(b.Owner),
"recovered", b.ID,
string(b.Owner), b.Value,
b.ID, b.Depth,
b.Value, b.BucketDepth,
b.Depth, b.Start,
b.BucketDepth, b.Immutable,
b.Start, ))
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