예제 #1
0
파일: state.go 프로젝트: ZhuZhengyi/eris-db
// Returns a hash that represents the state data, excluding Last*
func (s *State) Hash() []byte {
	return merkle.SimpleHashFromMap(map[string]interface{}{
		"BondedValidators":    s.BondedValidators,
		"UnbondingValidators": s.UnbondingValidators,
		"Accounts":            s.accounts,
		"ValidatorInfos":      s.validatorInfos,
		"NameRegistry":        s.nameReg,
	})
}
예제 #2
0
파일: block.go 프로젝트: ZhuZhengyi/eris-db
// NOTE: hash is nil if required fields are missing.
func (h *Header) Hash() []byte {
	if len(h.StateHash) == 0 {
		return nil
	}
	return merkle.SimpleHashFromMap(map[string]interface{}{
		"ChainID":        h.ChainID,
		"Height":         h.Height,
		"Time":           h.Time,
		"Fees":           h.Fees,
		"NumTxs":         h.NumTxs,
		"LastBlock":      h.LastBlockHash,
		"LastBlockParts": h.LastBlockParts,
		"LastValidation": h.LastValidationHash,
		"Data":           h.DataHash,
		"State":          h.StateHash,
	})
}