Skip to content

Commit

Permalink
Format godoc
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeliu committed Feb 25, 2019
1 parent e301969 commit 03d4afd
Show file tree
Hide file tree
Showing 81 changed files with 286 additions and 288 deletions.
2 changes: 1 addition & 1 deletion blockproducer/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ func (c *Chain) getLocalBPInfo() *blockProducerInfo {
return c.localBPInfo
}

// getRemoteBPInfos remove this node from the peer list
// getRemoteBPInfos remove this node from the peer list.
func (c *Chain) getRemoteBPInfos() (remoteBPInfos []*blockProducerInfo) {
var localBPInfo, bpInfos = func() (*blockProducerInfo, []*blockProducerInfo) {
c.RLock()
Expand Down
2 changes: 1 addition & 1 deletion blockproducer/interfaces/mixins.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (m *TransactionTypeMixin) SetTransactionType(t TransactionType) {
m.TxType = t
}

// GetTimestamp implements Transaciton.GetTimestamp()
// GetTimestamp implements Transaciton.GetTimestamp().
func (m *TransactionTypeMixin) GetTimestamp() time.Time {
return m.Timestamp
}
Expand Down
2 changes: 1 addition & 1 deletion blockproducer/interfaces/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type TransactionState uint32
// x |
// | +------------------------------------[ Expire ]--> Expired
// |
// +----------------------------------------------------------------------> Not Found
// +----------------------------------------------------------------------> Not Found.
const (
TransactionStatePending TransactionState = iota
TransactionStatePacked
Expand Down
1 change: 0 additions & 1 deletion blockproducer/interfaces/transaction_gen_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
package interfaces

// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
2 changes: 1 addition & 1 deletion blockproducer/metastate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type metaState struct {
dirty, readonly *metaIndex
}

// MinerInfos is MinerInfo array
// MinerInfos is MinerInfo array.
type MinerInfos []*types.MinerInfo

// Len returns the length of the uints array.
Expand Down
2 changes: 1 addition & 1 deletion client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type conn struct {
follower *pconn
}

// pconn represents a connection to a peer
// pconn represents a connection to a peer.
type pconn struct {
parent *conn
ackCh chan *types.Ack
Expand Down
2 changes: 1 addition & 1 deletion client/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func Create(meta ResourceMeta) (dsn string, err error) {
return
}

// WaitDBCreation waits for database creation complete
// WaitDBCreation waits for database creation complete.
func WaitDBCreation(ctx context.Context, dsn string) (err error) {
dsnCfg, err := ParseDSN(dsn)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var (
stubNextNonce pi.AccountNonce = 1
)

// fake BPDB service
// fake BPDB service.
type stubBPService struct{}

func (s *stubBPService) QueryAccountTokenBalance(req *types.QueryAccountTokenBalanceReq,
Expand Down
2 changes: 1 addition & 1 deletion client/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/pkg/errors"
)

// ExecuteTx starts a transaction, and runs fn in it
// ExecuteTx starts a transaction, and runs fn in it.
func ExecuteTx(
ctx context.Context, db *sql.DB, txopts *sql.TxOptions, fn func(*sql.Tx) error,
) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cql-adapter/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Storage interface {
Exec(dbID string, query string, args ...interface{}) (affectedRows int64, lastInsertID int64, err error)
}

// golang does trick convert, use rowScanner to return the original result type in sqlite3 driver
// golang does trick convert, use rowScanner to return the original result type in sqlite3 driver.
type rowScanner struct {
fieldCnt int
column int // current column
Expand Down
2 changes: 1 addition & 1 deletion cmd/cql-fuse/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func min(a, b uint64) uint64 {

// blockRange describes a range of blocks.
// If the first and last block are the same, the effective data range
// will be: [startOffset, lastLength)
// will be: [startOffset, lastLength).
type blockRange struct {
start int // index of the start block
startOffset uint64 // starting offset within the first block
Expand Down
2 changes: 1 addition & 1 deletion cmd/cql-fuse/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func initSchema(db *sql.DB) error {
// create inserts a new node.
// parentID: inode ID of the parent directory.
// name: name of the new node
// node: new node
// node: new node.
func (cfs CFS) create(ctx context.Context, parentID uint64, name string, node *Node) error {
inode := node.toJSON()
const insertNode = `INSERT INTO fs_inode VALUES (?, ?)`
Expand Down
2 changes: 1 addition & 1 deletion cmd/cql-fuse/randbytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.
//
// Author: Marc Berhault (marc@cockroachlabs.com)
// Author: Marc Berhault (marc@cockroachlabs.com).
package main

import (
Expand Down
16 changes: 8 additions & 8 deletions cmd/cqld/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
CmdDeleteDatabase = "delete_database"
)

// LocalStorage holds consistent and storage struct
// LocalStorage holds consistent and storage struct.
type LocalStorage struct {
consistent *consistent.Consistent
*storage.Storage
Expand Down Expand Up @@ -228,13 +228,13 @@ func (s *LocalStorage) compileLog(payload *KayakPayload) (result *compiledLog, e
return
}

// KayakKVServer holds kayak.Runtime and LocalStorage
// KayakKVServer holds kayak.Runtime and LocalStorage.
type KayakKVServer struct {
Runtime *kayak.Runtime
KVStorage *LocalStorage
}

// Init implements consistent.Persistence
// Init implements consistent.Persistence.
func (s *KayakKVServer) Init(storePath string, initNodes []proto.Node) (err error) {
for _, n := range initNodes {
var nodeBuf *bytes.Buffer
Expand All @@ -256,13 +256,13 @@ func (s *KayakKVServer) Init(storePath string, initNodes []proto.Node) (err erro
return
}

// KayakPayload is the payload used in kayak Leader and Follower
// KayakPayload is the payload used in kayak Leader and Follower.
type KayakPayload struct {
Command string
Data []byte
}

// SetNode implements consistent.Persistence
// SetNode implements consistent.Persistence.
func (s *KayakKVServer) SetNode(node *proto.Node) (err error) {
nodeBuf, err := utils.EncodeMsgPack(node)
if err != nil {
Expand All @@ -282,13 +282,13 @@ func (s *KayakKVServer) SetNode(node *proto.Node) (err error) {
return
}

// DelNode implements consistent.Persistence
// DelNode implements consistent.Persistence.
func (s *KayakKVServer) DelNode(nodeID proto.NodeID) (err error) {
// no need to del node currently
return
}

// Reset implements consistent.Persistence
// Reset implements consistent.Persistence.
func (s *KayakKVServer) Reset() (err error) {
// no need to reset for kayak
return
Expand Down Expand Up @@ -413,7 +413,7 @@ func (s *KayakKVServer) GetAllDatabases() (instances []types.ServiceInstance, er
return
}

// GetAllNodeInfo implements consistent.Persistence
// GetAllNodeInfo implements consistent.Persistence.
func (s *KayakKVServer) GetAllNodeInfo() (nodes []proto.Node, err error) {
var result [][]interface{}
query := "SELECT `node` FROM `dht`;"
Expand Down
2 changes: 1 addition & 1 deletion conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils/log"
)

// these const specify the role of this app, which can be "miner", "blockProducer"
// these const specify the role of this app, which can be "miner", "blockProducer".
const (
MinerBuildTag = "M"
BlockProducerBuildTag = "B"
Expand Down
6 changes: 3 additions & 3 deletions consistent/consistent.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils/log"
)

// NodeKeys is NodeKey array
// NodeKeys is NodeKey array.
type NodeKeys []proto.NodeKey

// Len returns the length of the uints array.
Expand Down Expand Up @@ -173,7 +173,7 @@ func (c *Consistent) Set(nodes []proto.Node) (err error) {
return
}

// need c.Lock() before calling
// need c.Lock() before calling.
func (c *Consistent) add(node proto.Node) (err error) {
err = c.persist.SetNode(&node)
if err != nil {
Expand Down Expand Up @@ -235,7 +235,7 @@ func (c *Consistent) GetNeighbor(name string) (proto.Node, error) {
return *c.circle[c.sortedHashes[i]], nil
}

// GetNode returns an node by its node id
// GetNode returns an node by its node id.
func (c *Consistent) GetNode(name string) (*proto.Node, error) {
c.RLock()
defer c.RUnlock()
Expand Down
4 changes: 2 additions & 2 deletions consistent/consistent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func init() {
})
}

// CheckNum make int assertion
// CheckNum make int assertion.
func CheckNum(num, expected int, t *testing.T) {
if num != expected {
t.Errorf("got %d, expected %d", num, expected)
Expand Down Expand Up @@ -934,7 +934,7 @@ func BenchmarkGetTwoLarge(b *testing.B) {
}
}

// from @edsrzf on github:
// from @edsrzf on github:.
func TestAddCollision(t *testing.T) {
// These two strings produce several crc32 collisions after "|i" is
// appended added by Consistent.eltKey.
Expand Down
14 changes: 7 additions & 7 deletions consistent/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils/log"
)

// Persistence is the interface for consistent persistence
// Persistence is the interface for consistent persistence.
type Persistence interface {
Init(storePath string, initNode []proto.Node) (err error)
SetNode(node *proto.Node) (err error)
Expand All @@ -31,30 +31,30 @@ type Persistence interface {
GetAllNodeInfo() (nodes []proto.Node, err error)
}

// KMSStorage implements Persistence
// KMSStorage implements Persistence.
type KMSStorage struct{}

// Init implements Persistence interface
// Init implements Persistence interface.
func (s *KMSStorage) Init(storePath string, initNodes []proto.Node) (err error) {
return kms.InitPublicKeyStore(storePath, initNodes)
}

// SetNode implements Persistence interface
// SetNode implements Persistence interface.
func (s *KMSStorage) SetNode(node *proto.Node) (err error) {
return kms.SetNode(node)
}

// DelNode implements Persistence interface
// DelNode implements Persistence interface.
func (s *KMSStorage) DelNode(nodeID proto.NodeID) (err error) {
return kms.DelNode(nodeID)
}

// Reset implements Persistence interface
// Reset implements Persistence interface.
func (s *KMSStorage) Reset() (err error) {
return kms.ResetBucket()
}

// GetAllNodeInfo implements Persistence interface
// GetAllNodeInfo implements Persistence interface.
func (s *KMSStorage) GetAllNodeInfo() (nodes []proto.Node, err error) {
IDs, err := kms.GetAllNodeID()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion crypto/asymmetric/keyexchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ec "github.com/btcsuite/btcd/btcec"
// public key using Diffie-Hellman key exchange (ECDH) (RFC 4753).
// RFC5903 Section 9 states we should only return x.
// Key Feature:
// GenECDHSharedSecret(BPub, APriv) == GenECDHSharedSecret(APub, BPriv)
// GenECDHSharedSecret(BPub, APriv) == GenECDHSharedSecret(APub, BPriv).
func GenECDHSharedSecret(privateKey *PrivateKey, publicKey *PublicKey) []byte {
return ec.GenerateSharedSecret((*ec.PrivateKey)(privateKey), (*ec.PublicKey)(publicKey))
}
18 changes: 9 additions & 9 deletions crypto/asymmetric/keypair.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ type PrivateKey ec.PrivateKey
// public key without having to directly import the ecdsa package.
type PublicKey ec.PublicKey

// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message.
func (k PublicKey) Msgsize() (s int) {
s = hsp.BytesPrefixSize + ec.PubKeyBytesLenCompressed
return
}

// MarshalHash marshals for hash
// MarshalHash marshals for hash.
func (k *PublicKey) MarshalHash() (keyBytes []byte, err error) {
return k.MarshalBinary()
}

// MarshalBinary does the serialization
// MarshalBinary does the serialization.
func (k *PublicKey) MarshalBinary() (keyBytes []byte, err error) {
return k.Serialize(), nil
}

// UnmarshalBinary does the deserialization
// UnmarshalBinary does the deserialization.
func (k *PublicKey) UnmarshalBinary(keyBytes []byte) (err error) {
pubKeyI, ok := parsedPublicKeyCache.Load(string(keyBytes))
if ok {
Expand Down Expand Up @@ -98,7 +98,7 @@ func (k *PublicKey) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err
}

// IsEqual return true if two keys are equal
// IsEqual return true if two keys are equal.
func (k *PublicKey) IsEqual(public *PublicKey) bool {
return (*ec.PublicKey)(k).IsEqual((*ec.PublicKey)(public))
}
Expand All @@ -110,12 +110,12 @@ func (k *PublicKey) IsEqual(public *PublicKey) bool {
// SerializeCompressed.
//
// BenchmarkParsePublicKey-12 50000 39819 ns/op 2401 B/op 35 allocs/op
// BenchmarkParsePublicKey-12 1000000 1039 ns/op 384 B/op 9 allocs/op
// BenchmarkParsePublicKey-12 1000000 1039 ns/op 384 B/op 9 allocs/op.
func (k *PublicKey) Serialize() []byte {
return (*ec.PublicKey)(k).SerializeCompressed()
}

// ParsePubKey recovers the public key from pubKeyStr
// ParsePubKey recovers the public key from pubKeyStr.
func ParsePubKey(pubKeyStr []byte) (*PublicKey, error) {
key, err := ec.ParsePubKey(pubKeyStr, ec.S256())
return (*PublicKey)(key), err
Expand Down Expand Up @@ -145,7 +145,7 @@ func (private *PrivateKey) Serialize() []byte {
return paddedAppend(PrivateKeyBytesLen, b, private.D.Bytes())
}

// PubKey return the public key
// PubKey return the public key.
func (private *PrivateKey) PubKey() *PublicKey {
return (*PublicKey)((*ec.PrivateKey)(private).PubKey())
}
Expand All @@ -160,7 +160,7 @@ func paddedAppend(size uint, dst, src []byte) []byte {
return append(dst, src...)
}

// GenSecp256k1KeyPair generate Secp256k1(used by Bitcoin) key pair
// GenSecp256k1KeyPair generate Secp256k1(used by Bitcoin) key pair.
func GenSecp256k1KeyPair() (
privateKey *PrivateKey,
publicKey *PublicKey,
Expand Down
Loading

0 comments on commit 03d4afd

Please sign in to comment.