From 625cca1cca2e7bdfed7c83e39ba34d25050ed32c Mon Sep 17 00:00:00 2001 From: David Hill Date: Thu, 7 Apr 2022 22:17:50 -0400 Subject: [PATCH 1/2] stake: Use a single copy instead of a for loop. --- blockchain/stake/tickets.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/blockchain/stake/tickets.go b/blockchain/stake/tickets.go index e63666faa7..6c56eda59b 100644 --- a/blockchain/stake/tickets.go +++ b/blockchain/stake/tickets.go @@ -419,9 +419,7 @@ func LoadBestNode(dbTx database.Tx, height uint32, blockHash chainhash.Hash, hea node.nextWinners = make([]chainhash.Hash, 0) if node.height >= uint32(params.StakeValidationBeginHeight()-1) { node.nextWinners = make([]chainhash.Hash, len(state.NextWinners)) - for i := range state.NextWinners { - node.nextWinners[i] = state.NextWinners[i] - } + copy(node.nextWinners, state.NextWinners) // Calculate the final state from the block header. stateBuffer := make([]byte, 0, From 78ceda20dc0cbb4b20d35255d3c9c1eed642e036 Mon Sep 17 00:00:00 2001 From: David Hill Date: Thu, 7 Apr 2022 22:19:02 -0400 Subject: [PATCH 2/2] ecdsa: Fix test that randomly picks a component. --- dcrec/secp256k1/ecdsa/signature_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dcrec/secp256k1/ecdsa/signature_test.go b/dcrec/secp256k1/ecdsa/signature_test.go index df85c406b3..35aa04a391 100644 --- a/dcrec/secp256k1/ecdsa/signature_test.go +++ b/dcrec/secp256k1/ecdsa/signature_test.go @@ -617,7 +617,7 @@ func TestSignAndVerifyRandom(t *testing.T) { badSig := *sig randByte := rng.Intn(32) randBit := rng.Intn(7) - if randComponent := rng.Intn(1); randComponent == 0 { + if randComponent := rng.Intn(2); randComponent == 0 { badSigBytes := badSig.r.Bytes() badSigBytes[randByte] ^= 1 << randBit badSig.r.SetBytes(&badSigBytes)