forked from btcsuite/btcd
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lbry] refactored parallel hash computation location, other hash code
formatting
- Loading branch information
1 parent
f418b2b
commit 8a5340a
Showing
8 changed files
with
178 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package node | ||
|
||
import ( | ||
"github.com/btcsuite/btcd/chaincfg/chainhash" | ||
"github.com/btcsuite/btcd/claimtrie/param" | ||
) | ||
|
||
type HashV2Manager struct { | ||
Manager | ||
} | ||
|
||
func (nm *HashV2Manager) computeClaimHashes(name []byte) (*chainhash.Hash, int32) { | ||
|
||
n, err := nm.NodeAt(nm.Height(), name) | ||
if err != nil || n == nil { | ||
return nil, 0 | ||
} | ||
|
||
n.SortClaimsByBid() | ||
claimHashes := make([]*chainhash.Hash, 0, len(n.Claims)) | ||
for _, c := range n.Claims { | ||
if c.Status == Activated { // TODO: unit test this line | ||
claimHashes = append(claimHashes, calculateNodeHash(c.OutPoint, n.TakenOverAt)) | ||
} | ||
} | ||
if len(claimHashes) > 0 { | ||
return ComputeMerkleRoot(claimHashes), n.NextUpdate() | ||
} | ||
return nil, n.NextUpdate() | ||
} | ||
|
||
func (nm *HashV2Manager) Hash(name []byte) (*chainhash.Hash, int32) { | ||
|
||
if nm.Height() >= param.ActiveParams.AllClaimsInMerkleForkHeight { | ||
return nm.computeClaimHashes(name) | ||
} | ||
|
||
return nm.Manager.Hash(name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.