Skip to content

Commit

Permalink
Fix: block saving
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Aug 5, 2023
1 parent 3865259 commit 5d009b7
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions cmd/starknet-id/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,30 @@ func NewStore(pg postgres.Storage) Store {

// Save -
func (s Store) Save(ctx context.Context, blockCtx *BlockContext) error {
if blockCtx.isEmpty() {
return nil
}
since := time.Now()

tx, err := s.pg.Transactable.BeginTransaction(ctx)
if err != nil {
return err
}
defer tx.Close(ctx)

if err := s.saveAddresses(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
if err := s.saveStarknetId(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
if err := s.saveSubdomains(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
if err := s.addDomains(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
if err := s.saveFields(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
if !blockCtx.isEmpty() {

if err := s.saveAddresses(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
if err := s.saveStarknetId(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
if err := s.saveSubdomains(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
if err := s.addDomains(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
if err := s.saveFields(ctx, tx, blockCtx); err != nil {
return tx.HandleError(ctx, err)
}
}

if _, err := tx.Exec(ctx, `INSERT INTO state (name, last_height, last_time)
Expand Down

0 comments on commit 5d009b7

Please sign in to comment.