From 9161856b6cf56ab0812188e04dc97f9841dc289f Mon Sep 17 00:00:00 2001 From: paladz <453256728@qq.com> Date: Fri, 13 Apr 2018 21:28:13 +0800 Subject: [PATCH] edit for fix unit test --- mining/tensority/algorithm.go | 4 +++- mining/tensority/algorithm_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mining/tensority/algorithm.go b/mining/tensority/algorithm.go index f06dc095..7558e9eb 100644 --- a/mining/tensority/algorithm.go +++ b/mining/tensority/algorithm.go @@ -7,6 +7,8 @@ import ( "github.com/bytom/protocol/bc" ) +const maxAIHashCached = 2048 + func algorithm(hash, seed *bc.Hash) *bc.Hash { cache := calcSeedCache(seed.Bytes()) data := mulMatrix(hash.Bytes(), cache) @@ -27,7 +29,7 @@ type Cache struct { // NewCache create a cache struct func NewCache() *Cache { - return &Cache{lruCache: lru.New(1024)} + return &Cache{lruCache: lru.New(maxAIHashCached)} } // AddCache is used for add tensority calculate result diff --git a/mining/tensority/algorithm_test.go b/mining/tensority/algorithm_test.go index 6e59cad6..835216e0 100644 --- a/mining/tensority/algorithm_test.go +++ b/mining/tensority/algorithm_test.go @@ -119,7 +119,7 @@ func TestHash(t *testing.T) { bhhash := bc.NewHash(tt.blockHeader) bhseed := bc.NewHash(tt.seed) - result := Hash(&bhhash, &bhseed).Bytes() + result := algorithm(&bhhash, &bhseed).Bytes() var resArr [32]byte copy(resArr[:], result) -- 2.11.0