• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

s7techlab / hlf-sdk-go / 6615655079

23 Oct 2023 03:42PM UTC coverage: 4.092% (-1.7%) from 5.771%
6615655079

Pull #135

github

Nikita Neznaemov
write-struct 15
Pull Request #135: write-struct

2885 of 2885 new or added lines in 21 files covered. (100.0%)

446 of 10900 relevant lines covered (4.09%)

0.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/block/block_methods.go
1
package block
2

3
import (
4
        "strings"
5

6
        "github.com/golang/protobuf/ptypes/timestamp"
7
        "github.com/hyperledger/fabric-protos-go/peer"
8
)
9

10
func (x *Block) ValidEnvelopes() []*Envelope {
×
11
        var envs []*Envelope
×
12
        for _, e := range x.Data.Envelopes {
×
13
                if e.ValidationCode != peer.TxValidationCode_VALID {
×
14
                        continue
×
15
                }
16

17
                envs = append(envs, e)
×
18
        }
19

20
        return envs
×
21
}
22

23
func (x *Block) BlockDate() *timestamp.Timestamp {
×
24
        var max *timestamp.Timestamp
×
25
        for _, envelope := range x.ValidEnvelopes() {
×
26
                ts := envelope.GetPayload().GetHeader().GetChannelHeader().GetTimestamp()
×
27

×
28
                if ts.AsTime().After(max.AsTime()) {
×
29
                        max = ts
×
30
                }
×
31
        }
32
        return max
×
33
}
34

35
// Writes ONLY VALID writes from block
36
func (x *Block) Writes() []*Write {
×
37
        var blockWrites []*Write
×
38

×
39
        for _, e := range x.ValidEnvelopes() {
×
40
                for _, a := range e.TxActions() {
×
41
                        for _, rwSet := range a.NsReadWriteSet() {
×
42
                                for _, write := range rwSet.Rwset.Writes {
×
43
                                        blockWrite := &Write{
×
44
                                                KWWrite: write,
×
45

×
46
                                                Block:            x.GetHeader().GetNumber(),
×
47
                                                Chaincode:        a.ChaincodeSpec().GetChaincodeId().GetName(),
×
48
                                                ChaincodeVersion: a.ChaincodeSpec().GetChaincodeId().GetVersion(),
×
49
                                                Tx:               e.ChannelHeader().GetTxId(),
×
50
                                                Timestamp:        e.ChannelHeader().GetTimestamp(),
×
51
                                        }
×
52

×
53
                                        blockWrite.KeyObjectType, blockWrite.KeyAttrs = SplitCompositeKey(write.Key)
×
54
                                        // Normalized key without null byte
×
55
                                        blockWrite.Key = strings.Join(append([]string{blockWrite.KeyObjectType}, blockWrite.KeyAttrs...), "_")
×
56

×
57
                                        blockWrites = append(blockWrites, blockWrite)
×
58
                                }
×
59
                        }
60
                }
61
        }
62

63
        return blockWrites
×
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc