From 82a725abfa7e166a72e0a0e3d5237b2688dcb25d Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Tue, 1 Jan 2019 11:49:39 -0800 Subject: [PATCH 1/2] move trie and utils into internal --- beaconchain/libs/beaconchain.go | 5 +++-- client/txgen/main.go | 2 +- consensus/consensus.go | 2 +- consensus/consensus_test.go | 2 +- consensus/consensus_validator.go | 2 +- core/blockchain.go | 2 +- core/state/database.go | 2 +- internal/db/memory_db.go | 2 +- {trie => internal/trie}/database.go | 0 {trie => internal/trie}/encoding.go | 0 {trie => internal/trie}/encoding_test.go | 0 {trie => internal/trie}/errors.go | 0 {trie => internal/trie}/hasher.go | 0 {trie => internal/trie}/iterator.go | 0 {trie => internal/trie}/iterator_test.go | 0 {trie => internal/trie}/node.go | 0 {trie => internal/trie}/node_test.go | 0 {trie => internal/trie}/proof.go | 0 {trie => internal/trie}/proof_test.go | 0 {trie => internal/trie}/secure_trie.go | 0 {trie => internal/trie}/secure_trie_test.go | 0 {trie => internal/trie}/sync.go | 0 {trie => internal/trie}/sync_test.go | 0 {trie => internal/trie}/trie.go | 0 {trie => internal/trie}/trie_test.go | 0 {utils => internal/utils}/bytes.go | 0 {utils => internal/utils}/bytes_test.go | 0 {utils => internal/utils}/metrics.go | 0 {utils => internal/utils}/singleton.go | 0 {utils => internal/utils}/singleton_test.go | 0 {utils => internal/utils}/utils.go | 0 {utils => internal/utils}/utils_test.go | 0 newnode/newnode.go | 2 +- node/node_test.go | 2 +- proto/bcconn/bcconn_test.go | 2 +- 35 files changed, 13 insertions(+), 12 deletions(-) rename {trie => internal/trie}/database.go (100%) rename {trie => internal/trie}/encoding.go (100%) rename {trie => internal/trie}/encoding_test.go (100%) rename {trie => internal/trie}/errors.go (100%) rename {trie => internal/trie}/hasher.go (100%) rename {trie => internal/trie}/iterator.go (100%) rename {trie => internal/trie}/iterator_test.go (100%) rename {trie => internal/trie}/node.go (100%) rename {trie => internal/trie}/node_test.go (100%) rename {trie => internal/trie}/proof.go (100%) rename {trie => internal/trie}/proof_test.go (100%) rename {trie => internal/trie}/secure_trie.go (100%) rename {trie => internal/trie}/secure_trie_test.go (100%) rename {trie => internal/trie}/sync.go (100%) rename {trie => internal/trie}/sync_test.go (100%) rename {trie => internal/trie}/trie.go (100%) rename {trie => internal/trie}/trie_test.go (100%) rename {utils => internal/utils}/bytes.go (100%) rename {utils => internal/utils}/bytes_test.go (100%) rename {utils => internal/utils}/metrics.go (100%) rename {utils => internal/utils}/singleton.go (100%) rename {utils => internal/utils}/singleton_test.go (100%) rename {utils => internal/utils}/utils.go (100%) rename {utils => internal/utils}/utils_test.go (100%) diff --git a/beaconchain/libs/beaconchain.go b/beaconchain/libs/beaconchain.go index 8e61663cc..5365eed65 100644 --- a/beaconchain/libs/beaconchain.go +++ b/beaconchain/libs/beaconchain.go @@ -1,20 +1,21 @@ package beaconchain import ( - "github.com/harmony-one/harmony/beaconchain/rpc" "math/rand" "strconv" "sync" + "github.com/harmony-one/harmony/beaconchain/rpc" + "github.com/dedis/kyber" "github.com/harmony-one/harmony/crypto/pki" + "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/log" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/host" "github.com/harmony-one/harmony/p2p/p2pimpl" "github.com/harmony-one/harmony/proto/bcconn" proto_identity "github.com/harmony-one/harmony/proto/identity" - "github.com/harmony-one/harmony/utils" ) var mutex sync.Mutex diff --git a/client/txgen/main.go b/client/txgen/main.go index 9b97e022c..e34b34c59 100644 --- a/client/txgen/main.go +++ b/client/txgen/main.go @@ -13,13 +13,13 @@ import ( "github.com/harmony-one/harmony/client/txgen/txgen" "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/core/types" + "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/log" "github.com/harmony-one/harmony/newnode" "github.com/harmony-one/harmony/node" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/p2pimpl" proto_node "github.com/harmony-one/harmony/proto/node" - "github.com/harmony-one/harmony/utils" ) var ( diff --git a/consensus/consensus.go b/consensus/consensus.go index f6fb2582e..3ad200577 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -17,10 +17,10 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/crypto" "github.com/harmony-one/harmony/crypto/pki" + "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/log" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/host" - "github.com/harmony-one/harmony/utils" proto_node "github.com/harmony-one/harmony/proto/node" ) diff --git a/consensus/consensus_test.go b/consensus/consensus_test.go index 6c25d7427..f75c892da 100644 --- a/consensus/consensus_test.go +++ b/consensus/consensus_test.go @@ -3,9 +3,9 @@ package consensus import ( "testing" + "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/p2pimpl" - "github.com/harmony-one/harmony/utils" ) func TestNew(test *testing.T) { diff --git a/consensus/consensus_validator.go b/consensus/consensus_validator.go index c4e15151a..a91509c35 100644 --- a/consensus/consensus_validator.go +++ b/consensus/consensus_validator.go @@ -9,8 +9,8 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/crypto" "github.com/harmony-one/harmony/internal/attack" + "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/log" - "github.com/harmony-one/harmony/utils" ) // ProcessMessageValidator dispatches validator's consensus message. diff --git a/core/blockchain.go b/core/blockchain.go index 04adef182..44f7f21c8 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -42,7 +42,7 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" hdb "github.com/harmony-one/harmony/internal/db" - "github.com/harmony-one/harmony/trie" + "github.com/harmony-one/harmony/internal/trie" "github.com/hashicorp/golang-lru" ) diff --git a/core/state/database.go b/core/state/database.go index 2c38a2360..8529163a4 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -22,7 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/harmony-one/harmony/internal/db" - "github.com/harmony-one/harmony/trie" + "github.com/harmony-one/harmony/internal/trie" lru "github.com/hashicorp/golang-lru" ) diff --git a/internal/db/memory_db.go b/internal/db/memory_db.go index 19ed73011..f81e0e797 100644 --- a/internal/db/memory_db.go +++ b/internal/db/memory_db.go @@ -4,7 +4,7 @@ import ( "errors" "sync" - "github.com/harmony-one/harmony/utils" + "github.com/harmony-one/harmony/internal/utils" ) // MemDatabase is the test memory database. It won't be used for any production. diff --git a/trie/database.go b/internal/trie/database.go similarity index 100% rename from trie/database.go rename to internal/trie/database.go diff --git a/trie/encoding.go b/internal/trie/encoding.go similarity index 100% rename from trie/encoding.go rename to internal/trie/encoding.go diff --git a/trie/encoding_test.go b/internal/trie/encoding_test.go similarity index 100% rename from trie/encoding_test.go rename to internal/trie/encoding_test.go diff --git a/trie/errors.go b/internal/trie/errors.go similarity index 100% rename from trie/errors.go rename to internal/trie/errors.go diff --git a/trie/hasher.go b/internal/trie/hasher.go similarity index 100% rename from trie/hasher.go rename to internal/trie/hasher.go diff --git a/trie/iterator.go b/internal/trie/iterator.go similarity index 100% rename from trie/iterator.go rename to internal/trie/iterator.go diff --git a/trie/iterator_test.go b/internal/trie/iterator_test.go similarity index 100% rename from trie/iterator_test.go rename to internal/trie/iterator_test.go diff --git a/trie/node.go b/internal/trie/node.go similarity index 100% rename from trie/node.go rename to internal/trie/node.go diff --git a/trie/node_test.go b/internal/trie/node_test.go similarity index 100% rename from trie/node_test.go rename to internal/trie/node_test.go diff --git a/trie/proof.go b/internal/trie/proof.go similarity index 100% rename from trie/proof.go rename to internal/trie/proof.go diff --git a/trie/proof_test.go b/internal/trie/proof_test.go similarity index 100% rename from trie/proof_test.go rename to internal/trie/proof_test.go diff --git a/trie/secure_trie.go b/internal/trie/secure_trie.go similarity index 100% rename from trie/secure_trie.go rename to internal/trie/secure_trie.go diff --git a/trie/secure_trie_test.go b/internal/trie/secure_trie_test.go similarity index 100% rename from trie/secure_trie_test.go rename to internal/trie/secure_trie_test.go diff --git a/trie/sync.go b/internal/trie/sync.go similarity index 100% rename from trie/sync.go rename to internal/trie/sync.go diff --git a/trie/sync_test.go b/internal/trie/sync_test.go similarity index 100% rename from trie/sync_test.go rename to internal/trie/sync_test.go diff --git a/trie/trie.go b/internal/trie/trie.go similarity index 100% rename from trie/trie.go rename to internal/trie/trie.go diff --git a/trie/trie_test.go b/internal/trie/trie_test.go similarity index 100% rename from trie/trie_test.go rename to internal/trie/trie_test.go diff --git a/utils/bytes.go b/internal/utils/bytes.go similarity index 100% rename from utils/bytes.go rename to internal/utils/bytes.go diff --git a/utils/bytes_test.go b/internal/utils/bytes_test.go similarity index 100% rename from utils/bytes_test.go rename to internal/utils/bytes_test.go diff --git a/utils/metrics.go b/internal/utils/metrics.go similarity index 100% rename from utils/metrics.go rename to internal/utils/metrics.go diff --git a/utils/singleton.go b/internal/utils/singleton.go similarity index 100% rename from utils/singleton.go rename to internal/utils/singleton.go diff --git a/utils/singleton_test.go b/internal/utils/singleton_test.go similarity index 100% rename from utils/singleton_test.go rename to internal/utils/singleton_test.go diff --git a/utils/utils.go b/internal/utils/utils.go similarity index 100% rename from utils/utils.go rename to internal/utils/utils.go diff --git a/utils/utils_test.go b/internal/utils/utils_test.go similarity index 100% rename from utils/utils_test.go rename to internal/utils/utils_test.go diff --git a/newnode/newnode.go b/newnode/newnode.go index 6aa086fa2..550749f7c 100644 --- a/newnode/newnode.go +++ b/newnode/newnode.go @@ -10,12 +10,12 @@ import ( "github.com/dedis/kyber" "github.com/harmony-one/harmony/crypto" + "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/log" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/host" "github.com/harmony-one/harmony/proto/bcconn" proto_identity "github.com/harmony-one/harmony/proto/identity" - "github.com/harmony-one/harmony/utils" ) //NewNode is ther struct for a candidate node diff --git a/node/node_test.go b/node/node_test.go index cd9b4c8e8..be81039e2 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -9,10 +9,10 @@ import ( "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/crypto" "github.com/harmony-one/harmony/crypto/pki" + "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/p2pimpl" proto_node "github.com/harmony-one/harmony/proto/node" - "github.com/harmony-one/harmony/utils" ) func TestNewNewNode(t *testing.T) { diff --git a/proto/bcconn/bcconn_test.go b/proto/bcconn/bcconn_test.go index ab8aaf70c..d55ce30e5 100644 --- a/proto/bcconn/bcconn_test.go +++ b/proto/bcconn/bcconn_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" + "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/p2p" - "github.com/harmony-one/harmony/utils" ) func TestSerializeDeserializeNodeInfo(t *testing.T) { From 39640643bdf17e07b597e2a8b88994fd38c497d3 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Tue, 1 Jan 2019 11:56:43 -0800 Subject: [PATCH 2/2] fix import --- beaconchain/libs/beaconchain.go | 4 ++-- newnode/newnode.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/beaconchain/libs/beaconchain.go b/beaconchain/libs/beaconchain.go index 5365eed65..780482dc4 100644 --- a/beaconchain/libs/beaconchain.go +++ b/beaconchain/libs/beaconchain.go @@ -5,9 +5,9 @@ import ( "strconv" "sync" - "github.com/harmony-one/harmony/beaconchain/rpc" - "github.com/dedis/kyber" + + "github.com/harmony-one/harmony/beaconchain/rpc" "github.com/harmony-one/harmony/crypto/pki" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/log" diff --git a/newnode/newnode.go b/newnode/newnode.go index 550749f7c..ea3b9d8cd 100644 --- a/newnode/newnode.go +++ b/newnode/newnode.go @@ -6,14 +6,14 @@ import ( "strconv" "time" - "github.com/harmony-one/harmony/p2p/p2pimpl" - "github.com/dedis/kyber" + "github.com/harmony-one/harmony/crypto" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/log" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/host" + "github.com/harmony-one/harmony/p2p/p2pimpl" "github.com/harmony-one/harmony/proto/bcconn" proto_identity "github.com/harmony-one/harmony/proto/identity" )