aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-11-29 10:20:00 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:54 +0800
commitd09c4f37a430b03e42d0ae3324907f040adc1449 (patch)
tree05f27af84647a2d3296a8d4fec578c11c5a1f87a
parent25a0e3a6b67cf646611153599e5b9cde2f2e8435 (diff)
downloaddexon-d09c4f37a430b03e42d0ae3324907f040adc1449.tar.gz
dexon-d09c4f37a430b03e42d0ae3324907f040adc1449.tar.zst
dexon-d09c4f37a430b03e42d0ae3324907f040adc1449.zip
Fix lint
-rw-r--r--.travis.yml3
-rw-r--r--core/genesis.go2
-rw-r--r--core/governance.go4
-rw-r--r--dex/app.go4
-rw-r--r--dex/backend.go2
-rw-r--r--dex/cache_test.go6
-rw-r--r--dex/downloader/downloader.go8
-rw-r--r--dex/downloader/metrics.go8
-rw-r--r--dex/handler_test.go8
-rw-r--r--dex/nodetable_test.go8
-rw-r--r--dex/peer.go14
-rw-r--r--dex/peer_test.go158
-rw-r--r--dex/protocol_test.go4
-rw-r--r--p2p/dial_test.go4
14 files changed, 119 insertions, 114 deletions
diff --git a/.travis.yml b/.travis.yml
index 63bdd953e..ee68b1b23 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,7 @@ matrix:
- sudo modprobe fuse
- sudo chmod 666 /dev/fuse
- sudo chown root:$USER /etc/fuse.conf
+ - make libbls
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES
@@ -23,6 +24,7 @@ matrix:
- sudo modprobe fuse
- sudo chmod 666 /dev/fuse
- sudo chown root:$USER /etc/fuse.conf
+ - make libbls
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES
@@ -38,6 +40,7 @@ matrix:
- ulimit -S -n $NOFILE
- ulimit -n
- unset -f cd # workaround for https://github.com/travis-ci/travis-ci/issues/8703
+ - make libbls
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES
diff --git a/core/genesis.go b/core/genesis.go
index 4b0e878fe..ce02249c9 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -261,7 +261,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
db = ethdb.NewMemDatabase()
}
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db))
- govStateHelper := vm.GovernanceStateHelper{statedb}
+ govStateHelper := vm.GovernanceStateHelper{StateDB: statedb}
totalStaked := big.NewInt(0)
diff --git a/core/governance.go b/core/governance.go
index dcc390eb4..4b625c0fa 100644
--- a/core/governance.go
+++ b/core/governance.go
@@ -54,7 +54,7 @@ func (g *Governance) GetHeadHelper() *vm.GovernanceStateHelper {
log.Error("Governance head state not ready", "err", err)
panic(err)
}
- return &vm.GovernanceStateHelper{headState}
+ return &vm.GovernanceStateHelper{StateDB: headState}
}
func (g *Governance) getHelperAtRound(round uint64) *vm.GovernanceStateHelper {
@@ -71,7 +71,7 @@ func (g *Governance) getHelperAtRound(round uint64) *vm.GovernanceStateHelper {
log.Error("Governance state not ready", "round", round, "height", height, "err", err)
panic(err)
}
- return &vm.GovernanceStateHelper{s}
+ return &vm.GovernanceStateHelper{StateDB: s}
}
func (g *Governance) GetConfigHelper(round uint64) *vm.GovernanceStateHelper {
diff --git a/dex/app.go b/dex/app.go
index 0e3f34f70..02e0a484f 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -39,7 +39,7 @@ const (
verifyBlockMaxRetries = 4
)
-// DexconApp implementes the DEXON consensus core application interface.
+// DexconApp implements the DEXON consensus core application interface.
type DexconApp struct {
txPool *core.TxPool
blockchain *core.BlockChain
@@ -382,7 +382,7 @@ func (d *DexconApp) VerifyBlock(block *coreTypes.Block) coreTypes.BlockVerifySta
log.Error("Failed to convert tx to message", "error", err)
return coreTypes.VerifyInvalidBlock
}
- balance, _ := addressesBalance[msg.From()]
+ balance := addressesBalance[msg.From()]
intrGas, err := core.IntrinsicGas(msg.Data(), msg.To() == nil, true)
if err != nil {
log.Error("Failed to calculate intrinsic gas", "err", err)
diff --git a/dex/backend.go b/dex/backend.go
index 8fe9e9ea3..550b1051a 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -46,7 +46,7 @@ import (
"github.com/dexon-foundation/dexon/rpc"
)
-// Dexon implementes the DEXON fullnode service.
+// Dexon implements the DEXON fullnode service.
type Dexon struct {
config *Config
chainConfig *params.ChainConfig
diff --git a/dex/cache_test.go b/dex/cache_test.go
index 3c04db673..ac5609c1a 100644
--- a/dex/cache_test.go
+++ b/dex/cache_test.go
@@ -145,9 +145,9 @@ func TestCacheBlock(t *testing.T) {
hashes := coreCommon.Hashes{block1.Hash, block2.Hash, block3.Hash, block4.Hash}
hashMap := map[coreCommon.Hash]struct{}{
- block1.Hash: struct{}{},
- block2.Hash: struct{}{},
- block3.Hash: struct{}{},
+ block1.Hash: {},
+ block2.Hash: {},
+ block3.Hash: {},
}
blocks := cache.blocks(hashes)
if len(blocks) != 3 {
diff --git a/dex/downloader/downloader.go b/dex/downloader/downloader.go
index 828c7c6bc..07c72262c 100644
--- a/dex/downloader/downloader.go
+++ b/dex/downloader/downloader.go
@@ -68,10 +68,10 @@ var (
reorgProtThreshold = 48 // Threshold number of recent blocks to disable mini reorg protection
reorgProtHeaderDelay = 2 // Number of headers to delay delivering to cover mini reorgs
- fsHeaderSafetyNet = 2048 // Number of headers to discard in case a chain violation is detected
- fsHeaderForceVerify = 24 // Number of headers to verify before and after the pivot to accept it
- fsHeaderContCheck = 3 * time.Second // Time interval to check for header continuations during state download
- fsMinFullBlocks = 64 // Number of blocks to retrieve fully even in fast sync
+ fsHeaderSafetyNet = 2048 // Number of headers to discard in case a chain violation is detected
+ // fsHeaderForceVerify = 24 // Number of headers to verify before and after the pivot to accept it
+ fsHeaderContCheck = 3 * time.Second // Time interval to check for header continuations during state download
+ fsMinFullBlocks = 64 // Number of blocks to retrieve fully even in fast sync
)
var (
diff --git a/dex/downloader/metrics.go b/dex/downloader/metrics.go
index 395950759..86f3298ad 100644
--- a/dex/downloader/metrics.go
+++ b/dex/downloader/metrics.go
@@ -28,10 +28,10 @@ var (
headerDropMeter = metrics.NewRegisteredMeter("dex/downloader/headers/drop", nil)
headerTimeoutMeter = metrics.NewRegisteredMeter("dex/downloader/headers/timeout", nil)
- govStateInMeter = metrics.NewRegisteredMeter("dex/downloader/govStates/in", nil)
- govStateReqTimer = metrics.NewRegisteredTimer("dex/downloader/govStates/req", nil)
- govStateDropMeter = metrics.NewRegisteredMeter("dex/downloader/govStates/drop", nil)
- govStateTimeoutMeter = metrics.NewRegisteredMeter("dex/downloader/govStates/timeout", nil)
+ govStateInMeter = metrics.NewRegisteredMeter("dex/downloader/govStates/in", nil)
+ // govStateReqTimer = metrics.NewRegisteredTimer("dex/downloader/govStates/req", nil)
+ govStateDropMeter = metrics.NewRegisteredMeter("dex/downloader/govStates/drop", nil)
+ // govStateTimeoutMeter = metrics.NewRegisteredMeter("dex/downloader/govStates/timeout", nil)
bodyInMeter = metrics.NewRegisteredMeter("dex/downloader/bodies/in", nil)
bodyReqTimer = metrics.NewRegisteredTimer("dex/downloader/bodies/req", nil)
diff --git a/dex/handler_test.go b/dex/handler_test.go
index c9e99abc9..d8398bd2d 100644
--- a/dex/handler_test.go
+++ b/dex/handler_test.go
@@ -239,10 +239,10 @@ func testGetBlockBodies(t *testing.T, protocol int) {
available []bool // Availability of explicitly requested blocks
expected int // Total number of existing blocks to expect
}{
- {1, nil, nil, 1}, // A single random block should be retrievable
- {10, nil, nil, 10}, // Multiple random blocks should be retrievable
- {limit, nil, nil, limit}, // The maximum possible blocks should be retrievable
- {limit + 1, nil, nil, limit}, // No more than the possible block count should be returned
+ {1, nil, nil, 1}, // A single random block should be retrievable
+ {10, nil, nil, 10}, // Multiple random blocks should be retrievable
+ {limit, nil, nil, limit}, // The maximum possible blocks should be retrievable
+ {limit + 1, nil, nil, limit}, // No more than the possible block count should be returned
{0, []common.Hash{pm.blockchain.Genesis().Hash()}, []bool{true}, 1}, // The genesis block should be retrievable
{0, []common.Hash{pm.blockchain.CurrentBlock().Hash()}, []bool{true}, 1}, // The chains head block should be retrievable
{0, []common.Hash{{}}, []bool{false}, 0}, // A non existent block should not be returned
diff --git a/dex/nodetable_test.go b/dex/nodetable_test.go
index 5adf0fbec..da00098a9 100644
--- a/dex/nodetable_test.go
+++ b/dex/nodetable_test.go
@@ -17,13 +17,13 @@ func TestNodeTable(t *testing.T) {
table.SubscribeNewMetasEvent(ch)
metas1 := []*NodeMeta{
- &NodeMeta{ID: randomID()},
- &NodeMeta{ID: randomID()},
+ {ID: randomID()},
+ {ID: randomID()},
}
metas2 := []*NodeMeta{
- &NodeMeta{ID: randomID()},
- &NodeMeta{ID: randomID()},
+ {ID: randomID()},
+ {ID: randomID()},
}
go table.Add(metas1)
diff --git a/dex/peer.go b/dex/peer.go
index 67aa50694..f60145f0d 100644
--- a/dex/peer.go
+++ b/dex/peer.go
@@ -67,12 +67,14 @@ const (
maxKnownMetas = 32768 // Maximum metas hashes to keep in the known list (prevent DOS)
maxKnownBlocks = 1024 // Maximum block hashes to keep in the known list (prevent DOS)
- maxKnownLatticeBLocks = 2048
- maxKnownVotes = 2048
- maxKnownAgreements = 10240
- maxKnownRandomnesses = 10240
- maxKnownDKGPrivateShare = 1024 // this related to DKG Size
- maxKnownDKGPartialSignature = 1024 // this related to DKG Size
+ /*
+ maxKnownLatticeBLocks = 2048
+ maxKnownVotes = 2048
+ maxKnownAgreements = 10240
+ maxKnownRandomnesses = 10240
+ maxKnownDKGPrivateShare = 1024 // this related to DKG Size
+ maxKnownDKGPartialSignature = 1024 // this related to DKG Size
+ */
// maxQueuedTxs is the maximum number of transaction lists to queue up before
// dropping broadcasts. This is a sensitive number as a transaction list might
diff --git a/dex/peer_test.go b/dex/peer_test.go
index 6c0804498..548a61052 100644
--- a/dex/peer_test.go
+++ b/dex/peer_test.go
@@ -30,19 +30,19 @@ func TestPeerSetBuildAndForgetNotaryConn(t *testing.T) {
}
round10 := [][]*enode.Node{
- []*enode.Node{self, nodes[1], nodes[2]},
- []*enode.Node{nodes[1], nodes[3]},
- []*enode.Node{nodes[2], nodes[4]},
+ {self, nodes[1], nodes[2]},
+ {nodes[1], nodes[3]},
+ {nodes[2], nodes[4]},
}
round11 := [][]*enode.Node{
- []*enode.Node{self, nodes[1], nodes[5]},
- []*enode.Node{nodes[5], nodes[6]},
- []*enode.Node{self, nodes[2], nodes[4]},
+ {self, nodes[1], nodes[5]},
+ {nodes[5], nodes[6]},
+ {self, nodes[2], nodes[4]},
}
round12 := [][]*enode.Node{
- []*enode.Node{self, nodes[3], nodes[5]},
- []*enode.Node{self, nodes[7], nodes[8]},
- []*enode.Node{self, nodes[2], nodes[6]},
+ {self, nodes[3], nodes[5]},
+ {self, nodes[7], nodes[8]},
+ {self, nodes[2], nodes[6]},
}
gov.notarySetFunc = func(
@@ -71,11 +71,11 @@ func TestPeerSetBuildAndForgetNotaryConn(t *testing.T) {
ps.BuildNotaryConn(10)
err = checkPeer2Labels(ps, map[string][]peerLabel{
- nodes[1].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 10},
+ nodes[1].ID().String(): {
+ {notaryset, 0, 10},
},
- nodes[2].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 10},
+ nodes[2].ID().String(): {
+ {notaryset, 0, 10},
},
})
if err != nil {
@@ -103,19 +103,19 @@ func TestPeerSetBuildAndForgetNotaryConn(t *testing.T) {
ps.BuildNotaryConn(11)
err = checkPeer2Labels(ps, map[string][]peerLabel{
- nodes[1].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 10},
- peerLabel{notaryset, 0, 11},
+ nodes[1].ID().String(): {
+ {notaryset, 0, 10},
+ {notaryset, 0, 11},
},
- nodes[2].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 10},
- peerLabel{notaryset, 2, 11},
+ nodes[2].ID().String(): {
+ {notaryset, 0, 10},
+ {notaryset, 2, 11},
},
- nodes[4].ID().String(): []peerLabel{
- peerLabel{notaryset, 2, 11},
+ nodes[4].ID().String(): {
+ {notaryset, 2, 11},
},
- nodes[5].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 11},
+ nodes[5].ID().String(): {
+ {notaryset, 0, 11},
},
})
if err != nil {
@@ -144,33 +144,33 @@ func TestPeerSetBuildAndForgetNotaryConn(t *testing.T) {
ps.BuildNotaryConn(12)
err = checkPeer2Labels(ps, map[string][]peerLabel{
- nodes[1].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 10},
- peerLabel{notaryset, 0, 11},
+ nodes[1].ID().String(): {
+ {notaryset, 0, 10},
+ {notaryset, 0, 11},
},
- nodes[2].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 10},
- peerLabel{notaryset, 2, 11},
- peerLabel{notaryset, 2, 12},
+ nodes[2].ID().String(): {
+ {notaryset, 0, 10},
+ {notaryset, 2, 11},
+ {notaryset, 2, 12},
},
- nodes[3].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 12},
+ nodes[3].ID().String(): {
+ {notaryset, 0, 12},
},
- nodes[4].ID().String(): []peerLabel{
- peerLabel{notaryset, 2, 11},
+ nodes[4].ID().String(): {
+ {notaryset, 2, 11},
},
- nodes[5].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 11},
- peerLabel{notaryset, 0, 12},
+ nodes[5].ID().String(): {
+ {notaryset, 0, 11},
+ {notaryset, 0, 12},
},
- nodes[6].ID().String(): []peerLabel{
- peerLabel{notaryset, 2, 12},
+ nodes[6].ID().String(): {
+ {notaryset, 2, 12},
},
- nodes[7].ID().String(): []peerLabel{
- peerLabel{notaryset, 1, 12},
+ nodes[7].ID().String(): {
+ {notaryset, 1, 12},
},
- nodes[8].ID().String(): []peerLabel{
- peerLabel{notaryset, 1, 12},
+ nodes[8].ID().String(): {
+ {notaryset, 1, 12},
},
})
if err != nil {
@@ -200,23 +200,23 @@ func TestPeerSetBuildAndForgetNotaryConn(t *testing.T) {
ps.ForgetNotaryConn(11)
err = checkPeer2Labels(ps, map[string][]peerLabel{
- nodes[2].ID().String(): []peerLabel{
- peerLabel{notaryset, 2, 12},
+ nodes[2].ID().String(): {
+ {notaryset, 2, 12},
},
- nodes[3].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 12},
+ nodes[3].ID().String(): {
+ {notaryset, 0, 12},
},
- nodes[5].ID().String(): []peerLabel{
- peerLabel{notaryset, 0, 12},
+ nodes[5].ID().String(): {
+ {notaryset, 0, 12},
},
- nodes[6].ID().String(): []peerLabel{
- peerLabel{notaryset, 2, 12},
+ nodes[6].ID().String(): {
+ {notaryset, 2, 12},
},
- nodes[7].ID().String(): []peerLabel{
- peerLabel{notaryset, 1, 12},
+ nodes[7].ID().String(): {
+ {notaryset, 1, 12},
},
- nodes[8].ID().String(): []peerLabel{
- peerLabel{notaryset, 1, 12},
+ nodes[8].ID().String(): {
+ {notaryset, 1, 12},
},
})
if err != nil {
@@ -277,9 +277,9 @@ func TestPeerSetBuildDKGConn(t *testing.T) {
gov.dkgSetFunc = func(round uint64) (map[string]struct{}, error) {
m := map[uint64][]*enode.Node{
- 10: []*enode.Node{self, nodes[1], nodes[2]},
- 11: []*enode.Node{nodes[1], nodes[2], nodes[5]},
- 12: []*enode.Node{self, nodes[3], nodes[5]},
+ 10: {self, nodes[1], nodes[2]},
+ 11: {nodes[1], nodes[2], nodes[5]},
+ 12: {self, nodes[3], nodes[5]},
}
return newTestNodeSet(m[round]), nil
}
@@ -300,11 +300,11 @@ func TestPeerSetBuildDKGConn(t *testing.T) {
ps.BuildDKGConn(10)
err = checkPeer2Labels(ps, map[string][]peerLabel{
- nodes[1].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 10},
+ nodes[1].ID().String(): {
+ {dkgset, 0, 10},
},
- nodes[2].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 10},
+ nodes[2].ID().String(): {
+ {dkgset, 0, 10},
},
})
if err != nil {
@@ -325,11 +325,11 @@ func TestPeerSetBuildDKGConn(t *testing.T) {
ps.BuildDKGConn(11)
err = checkPeer2Labels(ps, map[string][]peerLabel{
- nodes[1].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 10},
+ nodes[1].ID().String(): {
+ {dkgset, 0, 10},
},
- nodes[2].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 10},
+ nodes[2].ID().String(): {
+ {dkgset, 0, 10},
},
})
if err != nil {
@@ -350,17 +350,17 @@ func TestPeerSetBuildDKGConn(t *testing.T) {
ps.BuildDKGConn(12)
err = checkPeer2Labels(ps, map[string][]peerLabel{
- nodes[1].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 10},
+ nodes[1].ID().String(): {
+ {dkgset, 0, 10},
},
- nodes[2].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 10},
+ nodes[2].ID().String(): {
+ {dkgset, 0, 10},
},
- nodes[3].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 12},
+ nodes[3].ID().String(): {
+ {dkgset, 0, 12},
},
- nodes[5].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 12},
+ nodes[5].ID().String(): {
+ {dkgset, 0, 12},
},
})
if err != nil {
@@ -381,11 +381,11 @@ func TestPeerSetBuildDKGConn(t *testing.T) {
ps.ForgetDKGConn(11)
err = checkPeer2Labels(ps, map[string][]peerLabel{
- nodes[3].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 12},
+ nodes[3].ID().String(): {
+ {dkgset, 0, 12},
},
- nodes[5].ID().String(): []peerLabel{
- peerLabel{dkgset, 0, 12},
+ nodes[5].ID().String(): {
+ {dkgset, 0, 12},
},
})
if err != nil {
@@ -438,7 +438,7 @@ func checkPeer2Labels(ps *peerSet, want map[string][]peerLabel) error {
for _, label := range wantLabels {
if _, ok := gotLabels[label]; !ok {
- fmt.Errorf("label: %+v not exists", label)
+ return fmt.Errorf("label: %+v not exists", label)
}
}
}
diff --git a/dex/protocol_test.go b/dex/protocol_test.go
index c2f9c00b2..1b380cac7 100644
--- a/dex/protocol_test.go
+++ b/dex/protocol_test.go
@@ -330,7 +330,7 @@ func TestRecvLatticeBlock(t *testing.T) {
},
Timestamp: time.Now().UTC(),
Acks: coreCommon.NewSortedHashes(coreCommon.Hashes([]coreCommon.Hash{
- coreCommon.Hash{101}, coreCommon.Hash{100}, coreCommon.Hash{102},
+ {101}, {100}, {102},
})),
Payload: []byte{3, 3, 3, 3, 3},
Witness: coreTypes.Witness{
@@ -385,7 +385,7 @@ func TestSendLatticeBlock(t *testing.T) {
},
Timestamp: time.Now().UTC(),
Acks: coreCommon.NewSortedHashes(coreCommon.Hashes([]coreCommon.Hash{
- coreCommon.Hash{101}, coreCommon.Hash{100}, coreCommon.Hash{102},
+ {101}, {100}, {102},
})),
Payload: []byte{3, 3, 3, 3, 3},
Witness: coreTypes.Witness{
diff --git a/p2p/dial_test.go b/p2p/dial_test.go
index f9122de6f..35e439798 100644
--- a/p2p/dial_test.go
+++ b/p2p/dial_test.go
@@ -613,7 +613,7 @@ func TestDialStateDirectDial(t *testing.T) {
func TestDialStateGroupDial(t *testing.T) {
groups := []*dialGroup{
- &dialGroup{
+ {
name: "g1",
nodes: map[enode.ID]*enode.Node{
uintID(1): newNode(uintID(1), nil),
@@ -621,7 +621,7 @@ func TestDialStateGroupDial(t *testing.T) {
},
num: 2,
},
- &dialGroup{
+ {
name: "g2",
nodes: map[enode.ID]*enode.Node{
uintID(2): newNode(uintID(2), nil),