Skip to content

Commit

Permalink
replace github.com/golang/protobuf with google.golang.org/protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdy authored and yilunzhang committed Sep 28, 2024
1 parent c6185d7 commit 6eecd7e
Show file tree
Hide file tree
Showing 23 changed files with 27 additions and 28 deletions.
7 changes: 3 additions & 4 deletions api/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import (
"context"
"errors"
"fmt"
"google.golang.org/protobuf/encoding/protowire"

"github.com/nknorg/nkn/v2/config"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/config"
"github.com/nknorg/nkn/v2/transaction"
"github.com/nknorg/nkn/v2/vault"
)
Expand Down Expand Up @@ -197,7 +196,7 @@ func MakeGenerateIDTransaction(ctx context.Context, pubkey []byte, wallet *vault
default:
}

txn, err = transaction.NewGenerateIDTransaction(pubkey, sender, regFee, maxVersion, nonce, txnFee, proto.EncodeVarint(i))
txn, err = transaction.NewGenerateIDTransaction(pubkey, sender, regFee, maxVersion, nonce, txnFee, protowire.AppendVarint(nil, i))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion api/websocket/server/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"fmt"
"time"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/por"
"github.com/nknorg/nkn/v2/util/address"
"github.com/nknorg/nkn/v2/util/log"
"google.golang.org/protobuf/proto"
)

type sigChainInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion api/websocket/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"sync"
"time"

"github.com/golang/protobuf/proto"
api "github.com/nknorg/nkn/v2/api/common"
"github.com/nknorg/nkn/v2/api/common/errcode"
"github.com/nknorg/nkn/v2/api/webrtc"
Expand All @@ -34,6 +33,7 @@ import (
"github.com/nknorg/nkn/v2/util/address"
"github.com/nknorg/nkn/v2/util/log"
"github.com/nknorg/nkn/v2/vault"
"google.golang.org/protobuf/proto"

"github.com/gorilla/websocket"
)
Expand Down
2 changes: 1 addition & 1 deletion block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"fmt"
"io"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/common/serialization"
"github.com/nknorg/nkn/v2/config"
"github.com/nknorg/nkn/v2/crypto"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/signature"
"github.com/nknorg/nkn/v2/transaction"
"google.golang.org/protobuf/proto"
)

type Block struct {
Expand Down
2 changes: 1 addition & 1 deletion block/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

"github.com/nknorg/nkn/v2/crypto"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/common/serialization"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/program"
"github.com/nknorg/nkn/v2/signature"
"google.golang.org/protobuf/proto"
)

type Header struct {
Expand Down
2 changes: 1 addition & 1 deletion chain/blockvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/nknorg/nkn/v2/chain/txvalidator"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/block"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/config"
Expand All @@ -21,6 +20,7 @@ import (
"github.com/nknorg/nkn/v2/program"
"github.com/nknorg/nkn/v2/transaction"
"github.com/nknorg/nkn/v2/util"
"google.golang.org/protobuf/proto"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion chain/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"io"
"sync"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/block"
"github.com/nknorg/nkn/v2/chain/db"
"github.com/nknorg/nkn/v2/common"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/nknorg/nkn/v2/program"
"github.com/nknorg/nkn/v2/transaction"
"github.com/nknorg/nkn/v2/util/log"
"google.golang.org/protobuf/proto"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion consensus/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"crypto/sha256"
"fmt"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/block"
"github.com/nknorg/nkn/v2/chain"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/node"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/transaction"
"google.golang.org/protobuf/proto"
)

// NewVoteMessage creates a VOTE message
Expand Down
2 changes: 1 addition & 1 deletion consensus/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"sync"
"time"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/block"
"github.com/nknorg/nkn/v2/chain"
"github.com/nknorg/nkn/v2/common"
Expand All @@ -22,6 +21,7 @@ import (
"github.com/nknorg/nkn/v2/transaction"
"github.com/nknorg/nkn/v2/util/log"
"github.com/nknorg/nkn/v2/util/timer"
"google.golang.org/protobuf/proto"
)

type requestProposalInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"sync"
"time"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/chain"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/node"
Expand All @@ -13,6 +12,7 @@ import (
"github.com/nknorg/nkn/v2/util"
"github.com/nknorg/nkn/v2/util/log"
"github.com/nknorg/nkn/v2/util/timer"
"google.golang.org/protobuf/proto"
)

// startGettingNeighborConsensusState periodically checks neighbors' majority
Expand Down
2 changes: 1 addition & 1 deletion lnode/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package lnode
import (
"fmt"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/crypto/ed25519"
"github.com/nknorg/nkn/v2/node"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/util/log"
nnetnode "github.com/nknorg/nnet/node"
"golang.org/x/crypto/nacl/box"
"google.golang.org/protobuf/proto"
)

func (localNode *LocalNode) ComputeSharedKey(remotePublicKey []byte) (*[node.SharedKeySize]byte, error) {
Expand Down
2 changes: 1 addition & 1 deletion lnode/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package lnode
import (
"encoding/hex"
"encoding/json"
"google.golang.org/protobuf/proto"
"time"

"github.com/nknorg/nkn/v2/node"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/util/log"
nnetnode "github.com/nknorg/nnet/node"
Expand Down
6 changes: 3 additions & 3 deletions lnode/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"bytes"
"errors"
"fmt"
pbnode "github.com/nknorg/nnet/protobuf/node"
"math"
"math/rand"
"net"
"net/url"
"sync"
"time"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/chain"
"github.com/nknorg/nkn/v2/config"
"github.com/nknorg/nkn/v2/crypto"
Expand All @@ -23,7 +23,7 @@ import (
"github.com/nknorg/nkn/v2/util/log"
nnetnode "github.com/nknorg/nnet/node"
"github.com/nknorg/nnet/overlay/chord"
nnetpb "github.com/nknorg/nnet/protobuf"
"google.golang.org/protobuf/proto"
)

const (
Expand Down Expand Up @@ -312,7 +312,7 @@ func (localNode *LocalNode) GetVotingNeighbors(filter func(*node.RemoteNode) boo
return localNode.getSampledNeighbors(localNode.votingNeighbors, config.VotingSampleChordNeighbor, config.VotingMinChordNeighbor, filter)
}

func (localNode *LocalNode) shouldConnectToNode(n *nnetpb.Node) error {
func (localNode *LocalNode) shouldConnectToNode(n *pbnode.Node) error {
if n.GetData() != nil {
nodeData := &pb.NodeData{}
err := proto.Unmarshal(n.Data, nodeData)
Expand Down
2 changes: 1 addition & 1 deletion lnode/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"sync"
"time"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/block"
"github.com/nknorg/nkn/v2/chain"
"github.com/nknorg/nkn/v2/chain/txvalidator"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/nknorg/nkn/v2/util/address"
"github.com/nknorg/nkn/v2/util/log"
"github.com/nknorg/nkn/v2/vault"
"google.golang.org/protobuf/proto"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion lnode/stateHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package lnode
import (
"errors"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/chain"
"github.com/nknorg/nkn/v2/chain/store"
"github.com/nknorg/nkn/v2/chain/trie"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/node"
"github.com/nknorg/nkn/v2/pb"
"google.golang.org/protobuf/proto"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion lnode/syncblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"sync"
"time"

"github.com/golang/protobuf/proto"
"github.com/nknorg/consequential"
"github.com/nknorg/nkn/v2/block"
"github.com/nknorg/nkn/v2/chain"
Expand All @@ -15,6 +14,7 @@ import (
"github.com/nknorg/nkn/v2/node"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/util/log"
"google.golang.org/protobuf/proto"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion lnode/syncrandaddr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"reflect"
"time"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/chain"
"github.com/nknorg/nkn/v2/chain/pool"
"github.com/nknorg/nkn/v2/common"
Expand All @@ -15,6 +14,7 @@ import (
"github.com/nknorg/nkn/v2/transaction"
"github.com/nknorg/nkn/v2/util"
"github.com/nknorg/nkn/v2/util/log"
"google.golang.org/protobuf/proto"
)

// Number of random neighbors to sync rand addr
Expand Down
2 changes: 1 addition & 1 deletion lnode/synctxnpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"sync"
"time"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/chain/pool"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/config"
Expand All @@ -16,6 +15,7 @@ import (
"github.com/nknorg/nkn/v2/transaction"
"github.com/nknorg/nkn/v2/util"
"github.com/nknorg/nkn/v2/util/log"
"google.golang.org/protobuf/proto"
)

// Number of random neighbors to sync txn pool
Expand Down
2 changes: 1 addition & 1 deletion pb/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"io"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/common/serialization"
"google.golang.org/protobuf/proto"
)

// Serialize the Program
Expand Down
2 changes: 1 addition & 1 deletion por/porpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"bytes"
"errors"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/config"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/transaction"
"google.golang.org/protobuf/proto"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion transaction/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package transaction
import (
"errors"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/pb"
"google.golang.org/protobuf/proto"
)

func Pack(plType pb.PayloadType, payload proto.Message) (*pb.Payload, error) {
Expand Down
2 changes: 1 addition & 1 deletion transaction/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"errors"
"io"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/common"
"github.com/nknorg/nkn/v2/common/serialization"
"github.com/nknorg/nkn/v2/pb"
"github.com/nknorg/nkn/v2/program"
"github.com/nknorg/nkn/v2/signature"
"google.golang.org/protobuf/proto"
)

type Transaction struct {
Expand Down
2 changes: 1 addition & 1 deletion util/bytes2sigchain/bytes2sigchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"regexp"
"strings"

"github.com/golang/protobuf/proto"
"github.com/nknorg/nkn/v2/pb"
"google.golang.org/protobuf/proto"
)

// Base64ToHex convert base64 string input to hex string output
Expand Down

0 comments on commit 6eecd7e

Please sign in to comment.