Skip to content

Commit

Permalink
Fix syncing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mike76-dev committed May 13, 2024
1 parent b5d0cb1 commit eaf4edc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif

ldflags= \
-X "github.com/mike76-dev/sia-satellite/internal/build.BinaryName=satd" \
-X "github.com/mike76-dev/sia-satellite/internal/build.NodeVersion=0.11.4" \
-X "github.com/mike76-dev/sia-satellite/internal/build.NodeVersion=0.11.5" \
-X "github.com/mike76-dev/sia-satellite/internal/build.GitRevision=${GIT_DIRTY}${GIT_REVISION}" \
-X "github.com/mike76-dev/sia-satellite/internal/build.BuildTime=${BUILD_TIME}"

Expand Down
5 changes: 5 additions & 0 deletions modules/manager/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ func (m *Manager) initPersist(dir string) error {
}
defer m.tg.Done()

err := m.sync(m.tip)
if err != nil {
m.log.Error("failed to sync manager", zap.Error(err))
}

for {
select {
case <-m.tg.StopChan():
Expand Down
3 changes: 1 addition & 2 deletions modules/portal/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ func (p *Portal) addSiacoinPayment(email string, amount types.Currency, txid typ

// confirmSiacoinPayment decrements the number of remaining payment
// confirmations.
// A lock must be acquired before calling this function.
func (p *Portal) confirmSiacoinPayment(txid types.TransactionID) error {
tx, err := p.db.Begin()
if err != nil {
Expand Down Expand Up @@ -372,9 +373,7 @@ func (p *Portal) confirmSiacoinPayment(txid types.TransactionID) error {
// If the tx is confirmed, increase the account balance.
if left == 0 {
// Delete from the map.
p.mu.Lock()
delete(p.transactions, txid)
p.mu.Unlock()

// Fetch the account.
var c, id, in string
Expand Down
6 changes: 6 additions & 0 deletions modules/portal/portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ func New(config *persist.SatdConfig, db *sql.DB, ms mail.MailSender, cm *chain.M
}
defer pt.tg.Done()

err := pt.sync(pt.tip)
if err != nil {
pt.log.Error("couldn't sync portal", zap.Error(err))
return
}

for {
select {
case <-pt.tg.StopChan():
Expand Down

0 comments on commit eaf4edc

Please sign in to comment.