Update SSZ Dependency With Tree Hash Cache Enabled (#3076)

* utilize new SSZ

* workspace
This commit is contained in:
Raul Jordan 2019-07-25 23:49:49 -05:00 committed by GitHub
parent ed78f1f406
commit 40fca7bb2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -205,7 +205,7 @@ go_repository(
go_repository(
name = "com_github_prysmaticlabs_go_ssz",
commit = "16d4b0a834f2b17cdc19e3b63e967f15bf91fb1b",
commit = "48789cbaf046ec783a407a76c50a9cdd7507875b",
importpath = "github.com/prysmaticlabs/go-ssz",
)

View File

@ -6,6 +6,7 @@ import (
"github.com/prysmaticlabs/go-ssz"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/hashutil"
)
// VoteHierarchyMap struct that holds all the relevant data in order to count and
@ -35,10 +36,11 @@ func EmptyVoteHierarchyMap() *VoteHierarchyMap {
// CountVote takes a votecount map and adds the given vote to it in the relevant
// position while updating the best vote, most votes and best vote hash.
func CountVote(voteMap *VoteHierarchyMap, vote *ethpb.Eth1Data, blockHeight *big.Int) (*VoteHierarchyMap, error) {
he, err := ssz.HashedEncoding(vote)
encoded, err := ssz.Marshal(vote)
if err != nil {
return &VoteHierarchyMap{}, fmt.Errorf("could not get encoded hash of eth1data object: %v", err)
}
he := hashutil.Hash(encoded)
v, ok := voteMap.voteCountMap[string(he[:])]
if !ok {