[go: up one dir, main page]

Skip to content

Commit

Permalink
goimports -l -w fixes
Browse files Browse the repository at this point in the history
Go 1.19 is more unforgiving

Signed-off-by: James Taylor <jamest@uk.ibm.com>
  • Loading branch information
jt-nti authored and denyeart committed Oct 4, 2022
1 parent c60edc2 commit b33e614
Show file tree
Hide file tree
Showing 71 changed files with 337 additions and 281 deletions.
2 changes: 1 addition & 1 deletion bccsp/factory/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/factory/swfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/factory/swfactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/pkcs11/ecdsakey.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
48 changes: 25 additions & 23 deletions bccsp/pkcs11/pkcs11.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,18 @@ func (csp *Provider) getECKey(ski []byte) (pubKey *ecdsa.PublicKey, isPriv bool,

// RFC 5480, 2.1.1.1. Named Curve
//
// secp224r1 OBJECT IDENTIFIER ::= {
// iso(1) identified-organization(3) certicom(132) curve(0) 33 }
// secp224r1 OBJECT IDENTIFIER ::= {
// iso(1) identified-organization(3) certicom(132) curve(0) 33 }
//
// secp256r1 OBJECT IDENTIFIER ::= {
// iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3)
// prime(1) 7 }
// secp256r1 OBJECT IDENTIFIER ::= {
// iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3)
// prime(1) 7 }
//
// secp384r1 OBJECT IDENTIFIER ::= {
// iso(1) identified-organization(3) certicom(132) curve(0) 34 }
//
// secp521r1 OBJECT IDENTIFIER ::= {
// iso(1) identified-organization(3) certicom(132) curve(0) 35 }
// secp384r1 OBJECT IDENTIFIER ::= {
// iso(1) identified-organization(3) certicom(132) curve(0) 34 }
//
// secp521r1 OBJECT IDENTIFIER ::= {
// iso(1) identified-organization(3) certicom(132) curve(0) 35 }
var (
oidNamedCurveP224 = asn1.ObjectIdentifier{1, 3, 132, 0, 33}
oidNamedCurveP256 = asn1.ObjectIdentifier{1, 2, 840, 10045, 3, 1, 7}
Expand Down Expand Up @@ -755,18 +754,19 @@ func (csp *Provider) findKeyPairFromSKI(session pkcs11.SessionHandle, ski []byte
// 00000040 06 04
//
// cf. correct field:
// 0 89: SEQUENCE {
// 2 19: SEQUENCE {
// 4 7: OBJECT IDENTIFIER ecPublicKey (1 2 840 10045 2 1)
// 13 8: OBJECT IDENTIFIER prime256v1 (1 2 840 10045 3 1 7)
// : }
// 23 66: BIT STRING
// : 04 CE 30 31 6D 5A FD D3 53 2D 54 9A 27 54 D8 7C
// : D9 80 35 91 09 2D 6F 06 5A 8E E3 CB C0 01 B7 C9
// : 13 5D 70 D4 E5 62 F2 1B 10 93 F7 D5 77 41 BA 9D
// : 93 3E 18 3E 00 C6 0A 0E D2 36 CC 7F BE 50 16 EF
// : 06
// : }
//
// 0 89: SEQUENCE {
// 2 19: SEQUENCE {
// 4 7: OBJECT IDENTIFIER ecPublicKey (1 2 840 10045 2 1)
// 13 8: OBJECT IDENTIFIER prime256v1 (1 2 840 10045 3 1 7)
// : }
// 23 66: BIT STRING
// : 04 CE 30 31 6D 5A FD D3 53 2D 54 9A 27 54 D8 7C
// : D9 80 35 91 09 2D 6F 06 5A 8E E3 CB C0 01 B7 C9
// : 13 5D 70 D4 E5 62 F2 1B 10 93 F7 D5 77 41 BA 9D
// : 93 3E 18 3E 00 C6 0A 0E D2 36 CC 7F BE 50 16 EF
// : 06
// : }
//
// as a short-term workaround, remove the trailing byte if:
// - receiving an even number of bytes == 2*prime-coordinate +2 bytes
Expand All @@ -777,7 +777,9 @@ func (csp *Provider) findKeyPairFromSKI(session pkcs11.SessionHandle, ski []byte
//
// SoftHSM reports extra two bytes before the uncompressed point
// 0x04 || <Length*2+1>
// VV< Actual start of point
//
// VV< Actual start of point
//
// 00000000 04 41 04 6c c8 57 32 13 02 12 6a 19 23 1d 5a 64 |.A.l.W2...j.#.Zd|
// 00000010 33 0c eb 75 4d e8 99 22 92 35 96 b2 39 58 14 1e |3..uM..".5..9X..|
// 00000020 19 de ef 32 46 50 68 02 24 62 36 db ed b1 84 7b |...2FPh.$b6....{|
Expand Down
2 changes: 1 addition & 1 deletion bccsp/signer/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/aes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/aeskey.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/dummyks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/dummyks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/ecdsakey.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion bccsp/sw/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
4 changes: 2 additions & 2 deletions common/capabilities/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func (ap *ApplicationProvider) V1_3Validation() bool {

// V2_0Validation returns true if this channel supports transaction validation
// as introduced in v2.0. This includes:
// - new chaincode lifecycle
// - implicit per-org collections
// - new chaincode lifecycle
// - implicit per-org collections
func (ap *ApplicationProvider) V2_0Validation() bool {
return ap.v20 || ap.v25
}
Expand Down
13 changes: 6 additions & 7 deletions common/configtx/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ type ValidatorImpl struct {

// validateConfigID makes sure that the config element names (ie map key of
// ConfigGroup) comply with the following restrictions
// 1. Contain only ASCII alphanumerics, dots '.', dashes '-'
// 2. Are shorter than 250 characters.
// 3. Are not the strings "." or "..".
// 1. Contain only ASCII alphanumerics, dots '.', dashes '-'
// 2. Are shorter than 250 characters.
// 3. Are not the strings "." or "..".
func validateConfigID(configID string) error {
re, _ := regexp.Compile(configAllowedChars)
// Length
Expand All @@ -69,17 +69,16 @@ func validateConfigID(configID string) error {

// ValidateChannelID makes sure that proposed channel IDs comply with the
// following restrictions:
// 1. Contain only lower case ASCII alphanumerics, dots '.', and dashes '-'
// 2. Are shorter than 250 characters.
// 3. Start with a letter
// 1. Contain only lower case ASCII alphanumerics, dots '.', and dashes '-'
// 2. Are shorter than 250 characters.
// 3. Start with a letter
//
// This is the intersection of the Kafka restrictions and CouchDB restrictions
// with the following exception: '.' is converted to '_' in the CouchDB naming
// This is to accommodate existing channel names with '.', especially in the
// behave tests which rely on the dot notation for their sluggification.
//
// note: this function is a copy of the same in core/tx/endorser/parser.go
//
func ValidateChannelID(channelID string) error {
re, _ := regexp.Compile(ChannelAllowedChars)
// Length
Expand Down
7 changes: 3 additions & 4 deletions common/flogging/fabenc/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
)

// formatRegexp is broken into three groups:
// 1. the format verb
// 2. an optional colon that is ungrouped with '?:'
// 3. an optional, non-greedy format directive
// 1. the format verb
// 2. an optional colon that is ungrouped with '?:'
// 3. an optional, non-greedy format directive
//
// The grouping simplifies the verb proccssing during spec parsing.
var formatRegexp = regexp.MustCompile(`%{(color|id|level|message|module|shortfunc|time)(?::(.*?))?}`)
Expand All @@ -44,7 +44,6 @@ var formatRegexp = regexp.MustCompile(`%{(color|id|level|message|module|shortfun
// - level: a fmt style string formatter without the leading %
// - message: a fmt style string formatter without the leading %
// - module: a fmt style string formatter without the leading %
//
func ParseFormat(spec string) ([]Formatter, error) {
cursor := 0
formatters := []Formatter{}
Expand Down
3 changes: 2 additions & 1 deletion common/flogging/loggerlevels.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func (l *LoggerLevels) DefaultLevel() zapcore.Level {
// ActivateSpec is used to modify logging levels.
//
// The logging specification has the following form:
// [<logger>[,<logger>...]=]<level>[:[<logger>[,<logger>...]=]<level>...]
//
// [<logger>[,<logger>...]=]<level>[:[<logger>[,<logger>...]=]<level>...]
func (l *LoggerLevels) ActivateSpec(spec string) error {
l.mutex.Lock()
defer l.mutex.Unlock()
Expand Down
8 changes: 4 additions & 4 deletions common/ledger/blkstorage/block_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ type blockPlacementInfo struct {
blockBytesOffset int64
}

///////////////////////////////////
// /////////////////////////////////
// blockfileStream functions
////////////////////////////////////
// //////////////////////////////////
func newBlockfileStream(rootDir string, fileNum int, startOffset int64) (*blockfileStream, error) {
filePath := deriveBlockfilePath(rootDir, fileNum)
logger.Debugf("newBlockfileStream(): filePath=[%s], startOffset=[%d]", filePath, startOffset)
Expand Down Expand Up @@ -143,9 +143,9 @@ func (s *blockfileStream) close() error {
return errors.WithStack(s.file.Close())
}

///////////////////////////////////
// /////////////////////////////////
// blockStream functions
////////////////////////////////////
// //////////////////////////////////
func newBlockStream(rootDir string, startFileNum int, startOffset int64, endFileNum int) (*blockStream, error) {
startFileStream, err := newBlockfileStream(rootDir, startFileNum, startOffset)
if err != nil {
Expand Down
49 changes: 27 additions & 22 deletions common/ledger/blkstorage/blockfile_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ type blockfileMgr struct {
/*
Creates a new manager that will manage the files used for block persistence.
This manager manages the file system FS including
-- the directory where the files are stored
-- the individual files where the blocks are stored
-- the blockfilesInfo which tracks the latest file being persisted to
-- the index which tracks what block and transaction is in what file
-- the directory where the files are stored
-- the individual files where the blocks are stored
-- the blockfilesInfo which tracks the latest file being persisted to
-- the index which tracks what block and transaction is in what file
When a new blockfile manager is started (i.e. only on start-up), it checks
if this start-up is the first time the system is coming up or is this a restart
of the system.
Expand All @@ -60,29 +62,32 @@ i.e blockfile_000000, blockfile_000001, etc..
Each transaction in a block is stored with information about the number of
bytes in that transaction
Adding txLoc [fileSuffixNum=0, offset=3, bytesLength=104] for tx [1:0] to index
Adding txLoc [fileSuffixNum=0, offset=107, bytesLength=104] for tx [1:1] to index
Adding txLoc [fileSuffixNum=0, offset=3, bytesLength=104] for tx [1:0] to index
Adding txLoc [fileSuffixNum=0, offset=107, bytesLength=104] for tx [1:1] to index
Each block is stored with the total encoded length of that block as well as the
tx location offsets.
Remember that these steps are only done once at start-up of the system.
At start up a new manager:
*) Checks if the directory for storing files exists, if not creates the dir
*) Checks if the key value database exists, if not creates one
(will create a db dir)
*) Determines the blockfilesInfo used for storage
-- Loads from db if exist, if not instantiate a new blockfilesInfo
-- If blockfilesInfo was loaded from db, compares to FS
-- If blockfilesInfo and file system are not in sync, syncs blockfilesInfo from FS
*) Starts a new file writer
-- truncates file per blockfilesInfo to remove any excess past last block
*) Determines the index information used to find tx and blocks in
the file blkstorage
-- Instantiates a new blockIdxInfo
-- Loads the index from the db if exists
-- syncIndex comparing the last block indexed to what is in the FS
-- If index and file system are not in sync, syncs index from the FS
*) Updates blockchain info used by the APIs
*) Checks if the directory for storing files exists, if not creates the dir
*) Checks if the key value database exists, if not creates one
(will create a db dir)
*) Determines the blockfilesInfo used for storage
-- Loads from db if exist, if not instantiate a new blockfilesInfo
-- If blockfilesInfo was loaded from db, compares to FS
-- If blockfilesInfo and file system are not in sync, syncs blockfilesInfo from FS
*) Starts a new file writer
-- truncates file per blockfilesInfo to remove any excess past last block
*) Determines the index information used to find tx and blocks in
the file blkstorage
-- Instantiates a new blockIdxInfo
-- Loads the index from the db if exists
-- syncIndex comparing the last block indexed to what is in the FS
-- If index and file system are not in sync, syncs index from the FS
*) Updates blockchain info used by the APIs
*/
func newBlockfileMgr(id string, conf *Conf, indexConfig *IndexConfig, indexStore *leveldbhelper.DBHandle) (*blockfileMgr, error) {
logger.Debugf("newBlockfileMgr() initializing file-based block storage for ledger: %s ", id)
Expand Down
4 changes: 2 additions & 2 deletions common/ledger/blkstorage/blockfile_rw.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/pkg/errors"
)

//// WRITER ////
// // WRITER ////
type blockfileWriter struct {
filePath string
file *os.File
Expand Down Expand Up @@ -62,7 +62,7 @@ func (w *blockfileWriter) close() error {
return errors.WithStack(w.file.Close())
}

//// READER ////
// // READER ////
type blockfileReader struct {
file *os.File
}
Expand Down
3 changes: 2 additions & 1 deletion common/ledger/blockledger/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func (nfei *NotFoundErrorIterator) Close() {}
// CreateNextBlock provides a utility way to construct the next block from
// contents and metadata for a given ledger
// XXX This will need to be modified to accept marshaled envelopes
// to accommodate non-deterministic marshaling
//
// to accommodate non-deterministic marshaling
func CreateNextBlock(rl Reader, messages []*cb.Envelope) *cb.Block {
var nextBlockNumber uint64
var previousBlockHash []byte
Expand Down
Loading

0 comments on commit b33e614

Please sign in to comment.