Golang implemented sidechain for Bytom
修订版 | 45b11776fb251b712e0b11ec05fb54bb86ad1777 (tree) |
---|---|
时间 | 2021-01-26 16:49:54 |
作者 | paladz <colt@Colt...> |
Commiter | paladz |
try to fix the leak
@@ -2,25 +2,18 @@ | ||
2 | 2 | package sha3pool |
3 | 3 | |
4 | 4 | import ( |
5 | - "sync" | |
6 | - | |
7 | 5 | "golang.org/x/crypto/sha3" |
8 | 6 | ) |
9 | 7 | |
10 | -var pool = &sync.Pool{New: func() interface{} { return sha3.New256() }} | |
11 | - | |
12 | 8 | // Get256 returns an initialized SHA3-256 hash ready to use. |
13 | 9 | // It is like sha3.New256 except it uses the freelist. |
14 | 10 | // The caller should call Put256 when finished with the returned object. |
15 | 11 | func Get256() sha3.ShakeHash { |
16 | - return pool.Get().(sha3.ShakeHash) | |
12 | + return sha3.New256().(sha3.ShakeHash) | |
17 | 13 | } |
18 | 14 | |
19 | 15 | // Put256 resets h and puts it in the freelist. |
20 | -func Put256(h sha3.ShakeHash) { | |
21 | - h.Reset() | |
22 | - pool.Put(h) | |
23 | -} | |
16 | +func Put256(h sha3.ShakeHash) {} | |
24 | 17 | |
25 | 18 | // Sum256 uses a ShakeHash from the pool to sum into hash. |
26 | 19 | func Sum256(hash, data []byte) { |