[lint] fix ineffassign #708

pull/713/head
u5surf 6 years ago
parent 8d38f12425
commit a835435b4a
  1. 3
      api/proto/discovery/pingpong_test.go
  2. 15
      api/service/explorer/service.go
  3. 18
      consensus/consensus_validator_test.go
  4. 5
      node/contract.go
  5. 4
      node/demo_contract.go
  6. 7
      test/p2pchat/chat.go

@ -89,6 +89,9 @@ func TestSerialize(test *testing.T) {
buf2 = pong1.ConstructPongMessage()
msg2, err := proto.GetMessagePayload(buf2)
if err != nil {
test.Error("GetMessagePayload Failed!")
}
pong, err := GetPongMessage(msg2)
if err != nil {
test.Error("Pong failed!")

@ -146,12 +146,19 @@ func (s *Service) GetExplorerBlocks(w http.ResponseWriter, r *http.Request) {
}
db := s.storage.GetDB()
fromInt, err := strconv.Atoi(from)
if err != nil {
json.NewEncoder(w).Encode(data.Blocks)
return
}
var toInt int
if to == "" {
bytes, err := db.Get([]byte(BlockHeightKey))
if err == nil {
toInt, err = strconv.Atoi(string(bytes))
}
toInt, err = func() (int, error) {
bytes, err := db.Get([]byte(BlockHeightKey))
if err == nil {
return strconv.Atoi(string(bytes))
}
return toInt, err
}()
} else {
toInt, err = strconv.Atoi(to)
}

@ -79,8 +79,14 @@ func TestProcessMessageValidatorAnnounce(test *testing.T) {
test.Fatalf("Cannot craeate consensus: %v", err)
}
blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0")
if err != nil {
test.Fatalf("Cannot decode blockByte: %v", err)
}
consensusLeader.block = blockBytes
hashBytes, err := hex.DecodeString("bdd66a8211ffcbf0ad431b506c854b49264951fd9f690928e9cf44910c381053")
if err != nil {
test.Fatalf("Cannot decode hashByte: %v", err)
}
copy(consensusLeader.blockHash[:], hashBytes[:])
@ -140,8 +146,14 @@ func TestProcessMessageValidatorPrepared(test *testing.T) {
test.Fatalf("Cannot craeate consensus: %v", err)
}
blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0")
if err != nil {
test.Fatalf("Cannot decode blockByte: %v", err)
}
consensusLeader.block = blockBytes
hashBytes, err := hex.DecodeString("bdd66a8211ffcbf0ad431b506c854b49264951fd9f690928e9cf44910c381053")
if err != nil {
test.Fatalf("Cannot decode hashByte: %v", err)
}
copy(consensusLeader.blockHash[:], hashBytes[:])
@ -216,8 +228,14 @@ func TestProcessMessageValidatorCommitted(test *testing.T) {
test.Fatalf("Cannot craeate consensus: %v", err)
}
blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0")
if err != nil {
test.Fatalf("Cannot decode blockByte: %v", err)
}
consensusLeader.block = blockBytes
hashBytes, err := hex.DecodeString("bdd66a8211ffcbf0ad431b506c854b49264951fd9f690928e9cf44910c381053")
if err != nil {
test.Fatalf("Cannot decode hashByte: %v", err)
}
copy(consensusLeader.blockHash[:], hashBytes[:])

@ -75,6 +75,11 @@ func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue {
state, err := node.blockchain.State()
if err != nil {
utils.GetLogInstance().Error("Failed to get blockchain state", "error", err)
return nil
}
stakingContractAddress := crypto.CreateAddress(deployerAddress, uint64(0))
tx := types.NewTransaction(
state.GetNonce(deployerAddress),

@ -130,6 +130,10 @@ func (node *Node) GetResult(priKey string) (players []string, balances []*big.In
demoContractAddress := node.DemoContractAddress
key, err := crypto.HexToECDSA(priKey)
if err != nil {
utils.GetLogInstance().Error("Failed to parse private key", "error", err)
}
nonce := node.GetNonceOfAddress(crypto.PubkeyToAddress(key.PublicKey))
tx := types.NewTransaction(

@ -136,12 +136,17 @@ func main() {
}
if err != nil {
fmt.Printf("pubsub error: %v", err)
fmt.Printf("pub error: %v", err)
panic(err)
}
sub, err := ps.Subscribe("pubsubtestchannel")
if err != nil {
fmt.Printf("sub error: %v", err)
panic(err)
}
go writePubsub(ps)
go readPubsub(sub)

Loading…
Cancel
Save