Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(common/):add comments for complex funcs #5044

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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