Skip to content

Commit

Permalink
add transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
altitude committed Jun 18, 2021
1 parent 45e8834 commit 59c33d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func NewHttpAPI(lc fx.Lifecycle, l *ledger.Ledger) *HttpAPI {

err := l.Commit(t)

c.JSON(304, gin.H{
"ok": err != nil,
c.JSON(200, gin.H{
"ok": err == nil,
})
})

Expand Down
3 changes: 1 addition & 2 deletions ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (l *Ledger) Close() {

func (l *Ledger) Commit(t core.Transaction) error {
l.Lock()
defer l.Unlock()

count, _ := l.store.CountTransactions()
t.ID = count
Expand Down Expand Up @@ -134,8 +135,6 @@ func (l *Ledger) Commit(t core.Transaction) error {

l._last = &t

l.Unlock()

return err
}

Expand Down

0 comments on commit 59c33d1

Please sign in to comment.