Browse Source

do not use AddBatch, prefer copying for now

pull/835/head
Anton Kaliaev 7 years ago
parent
commit
a762253e24
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 16 additions and 5 deletions
  1. +16
    -5
      state/txindex/kv/kv.go

+ 16
- 5
state/txindex/kv/kv.go View File

@ -84,12 +84,23 @@ func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
// Index indexes a single transaction using the given list of tags.
func (txi *TxIndex) Index(result *types.TxResult) error {
batch := txindex.NewBatch(1)
err := batch.Add(result)
if err != nil {
return errors.Wrap(err, "failed to add tx result to batch")
b := txi.store.NewBatch()
hash := result.Tx.Hash()
// index tx by tags
for _, tag := range result.Result.Tags {
if cmn.StringInSlice(tag.Key, txi.tagsToIndex) {
b.Set(keyForTag(tag, result), hash)
}
}
return txi.AddBatch(batch)
// index tx by hash
rawBytes := wire.BinaryBytes(result)
b.Set(hash, rawBytes)
b.Write()
return nil
}
// Search performs a search using the given query. It breaks the query into


Loading…
Cancel
Save