diff --git a/api/censusdb/censusdb.go b/api/censusdb/censusdb.go index 639a39985..72f322326 100644 --- a/api/censusdb/censusdb.go +++ b/api/censusdb/censusdb.go @@ -289,7 +289,7 @@ func (c *CensusDB) List() ([]*CensusList, error) { c.Lock() defer c.Unlock() var list []*CensusList - if err := c.db.Iterate([]byte(censusDBreferencePrefix), func(key []byte, data []byte) bool { + if err := c.db.Iterate([]byte(censusDBreferencePrefix), func(key, data []byte) bool { censusID := make([]byte, len(key)) copy(censusID, key) dec := gob.NewDecoder(bytes.NewReader(data)) @@ -340,7 +340,7 @@ func (c *CensusDB) ExportCensusDB(buffer io.Writer) error { c.Lock() defer c.Unlock() // Iterate through all census entries in the DB - err := c.db.Iterate([]byte(censusDBreferencePrefix), func(key []byte, data []byte) bool { + err := c.db.Iterate([]byte(censusDBreferencePrefix), func(key, data []byte) bool { censusID := make([]byte, len(key)) copy(censusID, key) dec := gob.NewDecoder(bytes.NewReader(data)) diff --git a/api/wallet.go b/api/wallet.go index bec76a900..a4cdb30a9 100644 --- a/api/wallet.go +++ b/api/wallet.go @@ -398,12 +398,8 @@ func (a *API) walletElectionHandler(msg *apirest.APIdata, ctx *httprouter.HTTPCo Description: question.Description, Title: question.Title, } - for _, choice := range question.Choices { - metaQuestion.Choices = append(metaQuestion.Choices, ChoiceMetadata{ - Title: choice.Title, - Value: choice.Value, - }) - } + + metaQuestion.Choices = append(metaQuestion.Choices, question.Choices...) metadata.Questions = append(metadata.Questions, metaQuestion) } diff --git a/cmd/cli/editor.go b/cmd/cli/editor.go index 230217b06..90bb1e4c8 100644 --- a/cmd/cli/editor.go +++ b/cmd/cli/editor.go @@ -25,7 +25,7 @@ func GetPreferredEditorFromEnvironment() string { return editor } -func resolveEditorArguments(executable string, filename string) []string { +func resolveEditorArguments(executable, filename string) []string { args := []string{filename} if strings.Contains(executable, "Visual Studio Code.app") { diff --git a/data/ipfs/ipfs.go b/data/ipfs/ipfs.go index 4dc72c7aa..05ac211ae 100644 --- a/data/ipfs/ipfs.go +++ b/data/ipfs/ipfs.go @@ -88,7 +88,7 @@ func (i *Handler) Init(d *types.DataStore) error { } }() log.Infow("IPFS initialization", - "peerID", node.Identity.Pretty(), + "peerID", node.Identity.String(), "addresses", node.PeerHost.Addrs(), "pubKey", node.PrivateKey.GetPublic(), ) diff --git a/db/interface.go b/db/interface.go index 841b9b4ae..bc84f9f09 100644 --- a/db/interface.go +++ b/db/interface.go @@ -63,7 +63,7 @@ type WriteTx interface { // Set adds a key-value pair. If the key already exists, its value is // updated. - Set(key []byte, value []byte) error + Set(key, value []byte) error // Delete deletes a key and its value. Delete(key []byte) error // Apply applies the value-passed WriteTx into the given WriteTx, diff --git a/db/prefixeddb/prefixeddb.go b/db/prefixeddb/prefixeddb.go index ccc0d41ee..8b926a596 100644 --- a/db/prefixeddb/prefixeddb.go +++ b/db/prefixeddb/prefixeddb.go @@ -130,7 +130,7 @@ func (t *PrefixedWriteTx) Discard() { } // Set implements the db.WriteTx.Set interface method -func (t *PrefixedWriteTx) Set(key []byte, value []byte) error { +func (t *PrefixedWriteTx) Set(key, value []byte) error { return t.tx.Set(prefixSlice(t.prefix, key), value) } diff --git a/subpub/discovery.go b/subpub/discovery.go index 32370bbb7..938051843 100644 --- a/subpub/discovery.go +++ b/subpub/discovery.go @@ -85,7 +85,7 @@ func (s *SubPub) discover(ctx context.Context) { continue } cancel() - log.Infow("connected to cluster peer!", "address", peer.ID.Pretty()) + log.Infow("connected to cluster peer!", "address", peer.ID.String()) // protect the peer from being disconnected by the connection manager s.node.PeerHost.ConnManager().Protect(peer.ID, "discoveredPeer") diff --git a/subpub/gossipsub.go b/subpub/gossipsub.go index 33d616148..08b2354af 100644 --- a/subpub/gossipsub.go +++ b/subpub/gossipsub.go @@ -66,7 +66,7 @@ func (s *SubPub) joinGossip(ctx context.Context, p2pPS *pubsub.PubSub, selfID pe self: selfID, Messages: make(chan *Message, GossipBufSize), } - log.Infow("joined to gossipsub topic", "topic", sub.Topic(), "peer", selfID.Pretty()) + log.Infow("joined to gossipsub topic", "topic", sub.Topic(), "peer", selfID.String()) // start reading messages from the subscription in a loop go s.readGossipLoop() // this spawns a single background task per instance (since a single gossip topic is used) diff --git a/subpub/subpub.go b/subpub/subpub.go index 2dd982f07..cbf7c8bda 100644 --- a/subpub/subpub.go +++ b/subpub/subpub.go @@ -94,7 +94,7 @@ func (s *SubPub) Start(ctx context.Context, receiver chan *Message) { log.Fatal("no group key provided") } ipfslog.SetLogLevel("*", "ERROR") - s.NodeID = s.node.PeerHost.ID().Pretty() + s.NodeID = s.node.PeerHost.ID().String() s.messages = receiver s.setupDiscovery(ctx) s.setupGossip(ctx) diff --git a/test/api_test.go b/test/api_test.go index a9c483eb5..620e78654 100644 --- a/test/api_test.go +++ b/test/api_test.go @@ -298,8 +298,8 @@ func TestAPIElectionCost(t *testing.T) { func runAPIElectionCostWithParams(t *testing.T, electionParams electionprice.ElectionParameters, - startBlock uint32, initialBalance uint64, - txCostNewProcess, networkCapacity uint64, + startBlock uint32, initialBalance, + txCostNewProcess, networkCapacity, expectedPrice uint64, ) { server := testcommon.APIserver{} diff --git a/types/big.go b/types/big.go index d86ed9884..8f84217d9 100644 --- a/types/big.go +++ b/types/big.go @@ -48,17 +48,17 @@ func (i *BigInt) MathBigInt() *big.Int { } // Add sum x+y -func (i *BigInt) Add(x *BigInt, y *BigInt) *BigInt { +func (i *BigInt) Add(x, y *BigInt) *BigInt { return (*BigInt)(i.MathBigInt().Add(x.MathBigInt(), y.MathBigInt())) } // Sub subs x-y -func (i *BigInt) Sub(x *BigInt, y *BigInt) *BigInt { +func (i *BigInt) Sub(x, y *BigInt) *BigInt { return (*BigInt)(i.MathBigInt().Sub(x.MathBigInt(), y.MathBigInt())) } // Mul multiplies x*y -func (i *BigInt) Mul(x *BigInt, y *BigInt) *BigInt { +func (i *BigInt) Mul(x, y *BigInt) *BigInt { return (*BigInt)(i.MathBigInt().Mul(x.MathBigInt(), y.MathBigInt())) }