Skip to content

Commit

Permalink
docs(common/):add comments for complex funcs
Browse files Browse the repository at this point in the history
Signed-off-by: heren-ke <[email protected]>
  • Loading branch information
heren-ke authored and denyeart committed Oct 24, 2024
1 parent 38ca9e2 commit 73c2273
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/crypto/sanitize.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func SanitizeIdentity(identity []byte) ([]byte, error) {
return proto.Marshal(sID)
}

// SanitizeX509Cert sanitizes an X.509 certificate to ensure that the ECDSA signature uses a "low-S" value.
func SanitizeX509Cert(initialPEM []byte) ([]byte, error) {
der, _ := pem.Decode(initialPEM)
if der == nil {
Expand Down
2 changes: 2 additions & 0 deletions common/deliver/deliver.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ func isFiltered(srv *Server) bool {
return false
}

// deliverBlocks handles delivering blocks to the client from the blockchain channel.
// It processes a signed envelope from a client and responds with the requested blocks.
func (h *Handler) deliverBlocks(ctx context.Context, srv *Server, envelope *cb.Envelope) (status cb.Status, err error) {
addr := util.ExtractRemoteAddress(ctx)
payload, chdr, shdr, err := h.parseEnvelope(ctx, envelope)
Expand Down
3 changes: 3 additions & 0 deletions common/policies/bft.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const (
BlockValidationPolicyKey = "BlockValidation"
)

// EncodeBFTBlockVerificationPolicy creates a block verification policy based on Byzantine Fault Tolerance (BFT).
// It takes a list of consenters (orderer nodes), constructs a BFT policy using their identities, and updates
// the orderer's configuration group with this new policy.
func EncodeBFTBlockVerificationPolicy(consenterProtos []*cb.Consenter, ordererGroup *cb.ConfigGroup) {
n := len(consenterProtos)
f := (n - 1) / 3
Expand Down
5 changes: 5 additions & 0 deletions common/policydsl/policyparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func or(args ...interface{}) (interface{}, error) {
return outof(args...)
}

// firstPass processes a variadic list of arguments and returns a formatted string.
// The function expects arguments to be of either string, float32, or float64 types.
func firstPass(args ...interface{}) (interface{}, error) {
toret := "outof(ID"
for _, arg := range args {
Expand All @@ -115,6 +117,9 @@ func firstPass(args ...interface{}) (interface{}, error) {
return toret + ")", nil
}

// secondPass processes a list of arguments to build a "t-out-of-n" policy.
// It expects the first argument to be a context, the second an integer (threshold t),
// and the rest as either principals (strings) or pre-existing policies.
func secondPass(args ...interface{}) (interface{}, error) {
/* general sanity check, we expect at least 3 args */
if len(args) < 3 {
Expand Down

0 comments on commit 73c2273

Please sign in to comment.