Skip to content

Commit

Permalink
transform-read-state
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Neznaemov committed Apr 11, 2024
1 parent dbe8a62 commit 4a4b656
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 2 additions & 7 deletions block/transform/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"regexp"

"google.golang.org/protobuf/proto"

hlfproto "github.com/s7techlab/hlf-sdk-go/block"
)

Expand Down Expand Up @@ -72,10 +70,7 @@ func (s *Action) Transform(block *hlfproto.Block) (*hlfproto.Block, error) {
return nil, hlfproto.ErrNilBlock
}

// make block copy not to change original
blockCopy := proto.Clone(block).(*hlfproto.Block)

for _, envelope := range blockCopy.GetData().GetEnvelopes() {
for _, envelope := range block.GetData().GetEnvelopes() {
if envelope.GetPayload().GetTransaction() == nil {
continue
}
Expand Down Expand Up @@ -123,7 +118,7 @@ func (s *Action) Transform(block *hlfproto.Block) (*hlfproto.Block, error) {
}
}

return blockCopy, nil
return block, nil
}

func TxChaincodeIDMatch(chaincode string) TxActionMatch {
Expand Down
3 changes: 3 additions & 0 deletions block/transform/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ var LifecycleTransformers = []hlfproto.Transformer{
return nil
}),
),
),
NewAction(
TxChaincodeAnyMatch(),
WithKVReadTransformer(
KVReadKeyReplace(LifecycleStateKeyStrMapping(), func(read *kvrwset.KVRead) error {
read.Key = keyReplace(read.Key)
Expand Down

0 comments on commit 4a4b656

Please sign in to comment.