Skip to content

Commit

Permalink
always go through the batch
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Aug 12, 2024
1 parent 7bbd507 commit dfe74c7
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions activation/handler_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/spacemeshos/go-spacemesh/system"
)

var sqlWriterSleep = 100 * time.Millisecond
var sqlWriterSleep = 50 * time.Millisecond

type nipostValidatorV1 interface {
InitialNIPostChallengeV1(challenge *wire.NIPostChallengeV1, atxs atxProvider, goldenATXID types.ATXID) error
Expand Down Expand Up @@ -596,7 +596,6 @@ func (h *HandlerV1) storeAtx(
ctx context.Context,
atx *types.ActivationTx,
watx *wire.ActivationTxV1,
deps bool,
) (*mwire.MalfeasanceProof, error) {
var (
c chan struct{}
Expand All @@ -608,16 +607,12 @@ func (h *HandlerV1) storeAtx(
if err != nil {
return proof, fmt.Errorf("check malicious: %w", err)
}
if !deps {
h.atxMu.Lock()
h.atxBatch = append(h.atxBatch, atxBatchItem{atx: atx, watx: watx})
br = h.atxBatchResult
c = br.doneC
h.atxMu.Unlock()
} else {
// we have deps, persist with sync flow
return proof, h.storeAtxSync(ctx, atx, watx, proof)
}

h.atxMu.Lock()
h.atxBatch = append(h.atxBatch, atxBatchItem{atx: atx, watx: watx})
br = h.atxBatchResult
c = br.doneC
h.atxMu.Unlock()

select {
case <-c:
Expand Down Expand Up @@ -762,7 +757,7 @@ func (h *HandlerV1) processATX(
}
atx.Weight = weight

proof, err = h.storeAtx(ctx, atx, watx, len(atxIDs) > 0)
proof, err = h.storeAtx(ctx, atx, watx)
if err != nil {
return nil, fmt.Errorf("cannot store atx %s: %w", atx.ShortString(), err)
}
Expand Down

0 comments on commit dfe74c7

Please sign in to comment.