Skip to content

Commit

Permalink
Merge branch 'mnee' of https://github.com/shruggr/1sat-indexer into mnee
Browse files Browse the repository at this point in the history
  • Loading branch information
shruggr committed Mar 1, 2025
2 parents a001317 + e407e7d commit e137330
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 120 deletions.
10 changes: 8 additions & 2 deletions blk/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ func BlockByHeight(ctx context.Context, height uint32) (*BlockHeader, error) {
if err := json.NewDecoder(res.Body).Decode(&headers); err != nil {
return nil, err
}
for _, header := range headers {
if state, err := GetBlockState(ctx, header.Hash.String()); err != nil {
return nil, err
} else if state.State == "LONGEST_CHAIN" {
header.Height = state.Height
return &header, nil
}
}
header := &headers[0]
header.Height = height
return header, nil
Expand Down Expand Up @@ -163,8 +171,6 @@ func Blocks(ctx context.Context, fromBlock uint32, count uint) ([]*BlockHeader,
return results, nil
}
}
} else {
continue
}
}

Expand Down
60 changes: 0 additions & 60 deletions idx/pg-store/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,63 +77,3 @@ func (p *PGStore) UpdateAccount(ctx context.Context, account string, owners []st
}
return nil
}

// func (p *PGStore) SyncAcct(ctx context.Context, tag string, acct string, ing *idx.IngestCtx) error {
// if owners, err := p.AcctOwners(ctx, acct); err != nil {
// return err
// } else {
// for _, owner := range owners {
// if err := p.SyncOwner(ctx, tag, owner, ing); err != nil {
// log.Panic(err)
// return err
// }
// }
// }
// return nil
// }

// func (p *PGStore) SyncOwner(ctx context.Context, tag string, own string, ing *idx.IngestCtx) error {
// log.Println("Syncing:", own)
// if lastHeight, err := p.LogScore(ctx, idx.OwnerSyncKey, own); err != nil {
// log.Panic(err)
// } else if addTxns, err := jb.FetchOwnerTxns(own, int(lastHeight)); err != nil {
// log.Panic(err)
// } else {
// limiter := make(chan struct{}, ing.Concurrency)
// var wg sync.WaitGroup
// for _, addTxn := range addTxns {
// if score, err := p.LogScore(ctx, tag, addTxn.Txid); err != nil {
// log.Panic(err)
// return err
// } else if score > 0 {
// continue
// }
// wg.Add(1)
// limiter <- struct{}{}
// go func(addTxn *jb.AddressTxn) {
// defer func() {
// <-limiter
// wg.Done()
// }()
// if _, err := ing.IngestTxid(ctx, addTxn.Txid, idx.AncestorConfig{
// Load: true,
// Parse: true,
// Save: true,
// }); err != nil {
// log.Panic(err)
// }
// }(addTxn)

// if addTxn.Height > uint32(lastHeight) {
// lastHeight = float64(addTxn.Height)
// }
// }
// wg.Wait()
// if err := p.Log(ctx, idx.OwnerSyncKey, own, lastHeight); err != nil {
// log.Panic(err)
// return err
// }
// }

// return nil
// }
58 changes: 0 additions & 58 deletions idx/redis-store/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,61 +78,3 @@ func (r *RedisStore) UpdateAccount(ctx context.Context, account string, owners [

return err
}

// func (r *RedisStore) SyncAcct(ctx context.Context, tag string, acct string, ing *idx.IngestCtx) error {
// if owners, err := r.AcctOwners(ctx, acct); err != nil {
// return err
// } else {
// for _, owner := range owners {
// if err := r.SyncOwner(ctx, tag, owner, ing); err != nil {
// return err
// }
// }
// }
// return nil
// }

// func (r *RedisStore) SyncOwner(ctx context.Context, tag string, own string, ing *idx.IngestCtx) error {
// log.Println("Syncing:", own)
// if lastHeight, err := r.LogScore(ctx, idx.OwnerSyncKey, own); err != nil && err != redis.Nil {
// return err
// } else if addTxns, err := jb.FetchOwnerTxns(own, int(lastHeight)); err != nil {
// log.Panic(err)
// } else {
// limiter := make(chan struct{}, ing.Concurrency)
// var wg sync.WaitGroup
// for _, addTxn := range addTxns {
// if score, err := r.LogScore(ctx, tag, addTxn.Txid); err != nil {
// log.Panic(err)
// return err
// } else if score > 0 {
// continue
// }
// wg.Add(1)
// limiter <- struct{}{}
// go func(addTxn *jb.AddressTxn) {
// defer func() {
// <-limiter
// wg.Done()
// }()
// if _, err := ing.IngestTxid(ctx, addTxn.Txid, idx.AncestorConfig{
// Load: true,
// Parse: true,
// Save: true,
// }); err != nil {
// log.Panic(err)
// }
// }(addTxn)

// if addTxn.Height > uint32(lastHeight) {
// lastHeight = float64(addTxn.Height)
// }
// }
// wg.Wait()
// if err := r.Log(ctx, idx.OwnerSyncKey, own, lastHeight); err != nil {
// log.Panic(err)
// }
// }

// return nil
// }

0 comments on commit e137330

Please sign in to comment.