예제 #1
0
func (kv KVPair) Hash() []byte {
	hasher, n, err := ripemd160.New(), new(int64), new(error)
	wire.WriteString(kv.Key, hasher, n, err)
	if kvH, ok := kv.Value.(Hashable); ok {
		wire.WriteByteSlice(kvH.Hash(), hasher, n, err)
	} else {
		wire.WriteBinary(kv.Value, hasher, n, err)
	}
	if *err != nil {
		PanicSanity(*err)
	}
	return hasher.Sum(nil)
}
예제 #2
0
func (s *State) Save() {
	s.accounts.Save()
	s.validatorInfos.Save()
	s.nameReg.Save()
	buf, n, err := new(bytes.Buffer), new(int64), new(error)
	wire.WriteString(s.ChainID, buf, n, err)
	wire.WriteVarint(s.LastBlockHeight, buf, n, err)
	wire.WriteByteSlice(s.LastBlockHash, buf, n, err)
	wire.WriteBinary(s.LastBlockParts, buf, n, err)
	wire.WriteTime(s.LastBlockTime, buf, n, err)
	wire.WriteBinary(s.BondedValidators, buf, n, err)
	wire.WriteBinary(s.LastBondedValidators, buf, n, err)
	wire.WriteBinary(s.UnbondingValidators, buf, n, err)
	wire.WriteByteSlice(s.accounts.Hash(), buf, n, err)
	wire.WriteByteSlice(s.validatorInfos.Hash(), buf, n, err)
	wire.WriteByteSlice(s.nameReg.Hash(), buf, n, err)
	if *err != nil {
		PanicCrisis(*err)
	}
	s.DB.Set(stateKey, buf.Bytes())
}
예제 #3
0
파일: peer.go 프로젝트: jsp282/tendermint
func (p *Peer) WriteTo(w io.Writer) (n int64, err error) {
	wire.WriteString(p.Key, w, &n, &err)
	return
}