Skip to content

Commit

Permalink
comments fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmenendez committed Sep 7, 2023
1 parent a79910d commit 639800f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
13 changes: 1 addition & 12 deletions api/censuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,7 @@ func (capi *census3API) getCensus(msg *api.APIdata, ctx *httprouter.HTTPContext)
}
internalCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
// begin a transaction for group sql queries
tx, err := capi.db.RO.BeginTx(internalCtx, nil)
if err != nil {
return ErrCantGetCensus
}
defer func() {
if err := tx.Rollback(); err != nil {
log.Errorw(err, "holders transaction rollback failed")
}
}()
qtx := capi.db.QueriesRO.WithTx(tx)
currentCensus, err := qtx.CensusByID(internalCtx, int64(censusID))
currentCensus, err := capi.db.QueriesRO.CensusByID(internalCtx, int64(censusID))
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return ErrNotFoundCensus
Expand Down
6 changes: 3 additions & 3 deletions service/holder_scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func Test_saveHolders(t *testing.T) {
// check web3
c.Assert(hs.saveHolders(th), qt.IsNil)
// check new holders
res, err := testdb.db.QueriesRW.TokenHolderByTokenIDAndHolderID(context.Background(),
res, err := testdb.db.QueriesRO.TokenHolderByTokenIDAndHolderID(context.Background(),
queries.TokenHolderByTokenIDAndHolderIDParams{
TokenID: MonkeysAddress.Bytes(),
HolderID: holderAddr.Bytes(),
Expand All @@ -146,7 +146,7 @@ func Test_saveHolders(t *testing.T) {
// check update holders
th.Append(holderAddr, holderBalance)
c.Assert(hs.saveHolders(th), qt.IsNil)
res, err = testdb.db.QueriesRW.TokenHolderByTokenIDAndHolderID(context.Background(),
res, err = testdb.db.QueriesRO.TokenHolderByTokenIDAndHolderID(context.Background(),
queries.TokenHolderByTokenIDAndHolderIDParams{
TokenID: MonkeysAddress.Bytes(),
HolderID: holderAddr.Bytes(),
Expand All @@ -157,7 +157,7 @@ func Test_saveHolders(t *testing.T) {
// check delete holders
th.Append(holderAddr, big.NewInt(-24))
c.Assert(hs.saveHolders(th), qt.IsNil)
_, err = testdb.db.QueriesRW.TokenHolderByTokenIDAndHolderID(context.Background(),
_, err = testdb.db.QueriesRO.TokenHolderByTokenIDAndHolderID(context.Background(),
queries.TokenHolderByTokenIDAndHolderIDParams{
TokenID: MonkeysAddress.Bytes(),
HolderID: holderAddr.Bytes(),
Expand Down

0 comments on commit 639800f

Please sign in to comment.