switch to non length prefixed marshalling

This commit is contained in:
rhuairahrighairigh 2020-04-25 00:05:54 +01:00
parent 114097edb3
commit ccad1f82e2

View File

@ -45,14 +45,14 @@ func (k Keeper) GetCommittee(ctx sdk.Context, committeeID uint64) (types.Committ
return types.Committee{}, false return types.Committee{}, false
} }
var committee types.Committee var committee types.Committee
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &committee) k.cdc.MustUnmarshalBinaryBare(bz, &committee)
return committee, true return committee, true
} }
// SetCommittee puts a committee into the store. // SetCommittee puts a committee into the store.
func (k Keeper) SetCommittee(ctx sdk.Context, committee types.Committee) { func (k Keeper) SetCommittee(ctx sdk.Context, committee types.Committee) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.CommitteeKeyPrefix) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.CommitteeKeyPrefix)
bz := k.cdc.MustMarshalBinaryLengthPrefixed(committee) bz := k.cdc.MustMarshalBinaryBare(committee)
store.Set(types.GetKeyFromID(committee.ID), bz) store.Set(types.GetKeyFromID(committee.ID), bz)
} }
@ -70,7 +70,7 @@ func (k Keeper) IterateCommittees(ctx sdk.Context, cb func(committee types.Commi
defer iterator.Close() defer iterator.Close()
for ; iterator.Valid(); iterator.Next() { for ; iterator.Valid(); iterator.Next() {
var committee types.Committee var committee types.Committee
k.cdc.MustUnmarshalBinaryLengthPrefixed(iterator.Value(), &committee) k.cdc.MustUnmarshalBinaryBare(iterator.Value(), &committee)
if cb(committee) { if cb(committee) {
break break
@ -114,12 +114,12 @@ func (k Keeper) StoreNewProposal(ctx sdk.Context, pubProposal types.PubProposal,
if err != nil { if err != nil {
return 0, err return 0, err
} }
proposal := types.Proposal{ proposal := types.NewProposal(
PubProposal: pubProposal, pubProposal,
ID: newProposalID, newProposalID,
CommitteeID: committeeID, committeeID,
Deadline: deadline, deadline,
} )
k.SetProposal(ctx, proposal) k.SetProposal(ctx, proposal)
@ -138,14 +138,14 @@ func (k Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Proposal,
return types.Proposal{}, false return types.Proposal{}, false
} }
var proposal types.Proposal var proposal types.Proposal
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposal) k.cdc.MustUnmarshalBinaryBare(bz, &proposal)
return proposal, true return proposal, true
} }
// SetProposal puts a proposal into the store. // SetProposal puts a proposal into the store.
func (k Keeper) SetProposal(ctx sdk.Context, proposal types.Proposal) { func (k Keeper) SetProposal(ctx sdk.Context, proposal types.Proposal) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ProposalKeyPrefix) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ProposalKeyPrefix)
bz := k.cdc.MustMarshalBinaryLengthPrefixed(proposal) bz := k.cdc.MustMarshalBinaryBare(proposal)
store.Set(types.GetKeyFromID(proposal.ID), bz) store.Set(types.GetKeyFromID(proposal.ID), bz)
} }
@ -163,7 +163,7 @@ func (k Keeper) IterateProposals(ctx sdk.Context, cb func(proposal types.Proposa
defer iterator.Close() defer iterator.Close()
for ; iterator.Valid(); iterator.Next() { for ; iterator.Valid(); iterator.Next() {
var proposal types.Proposal var proposal types.Proposal
k.cdc.MustUnmarshalBinaryLengthPrefixed(iterator.Value(), &proposal) k.cdc.MustUnmarshalBinaryBare(iterator.Value(), &proposal)
if cb(proposal) { if cb(proposal) {
break break
@ -183,14 +183,14 @@ func (k Keeper) GetVote(ctx sdk.Context, proposalID uint64, voter sdk.AccAddress
return types.Vote{}, false return types.Vote{}, false
} }
var vote types.Vote var vote types.Vote
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &vote) k.cdc.MustUnmarshalBinaryBare(bz, &vote)
return vote, true return vote, true
} }
// SetVote puts a vote into the store. // SetVote puts a vote into the store.
func (k Keeper) SetVote(ctx sdk.Context, vote types.Vote) { func (k Keeper) SetVote(ctx sdk.Context, vote types.Vote) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VoteKeyPrefix) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VoteKeyPrefix)
bz := k.cdc.MustMarshalBinaryLengthPrefixed(vote) bz := k.cdc.MustMarshalBinaryBare(vote)
store.Set(types.GetVoteKey(vote.ProposalID, vote.Voter), bz) store.Set(types.GetVoteKey(vote.ProposalID, vote.Voter), bz)
} }
@ -209,7 +209,7 @@ func (k Keeper) IterateVotes(ctx sdk.Context, proposalID uint64, cb func(vote ty
defer iterator.Close() defer iterator.Close()
for ; iterator.Valid(); iterator.Next() { for ; iterator.Valid(); iterator.Next() {
var vote types.Vote var vote types.Vote
k.cdc.MustUnmarshalBinaryLengthPrefixed(iterator.Value(), &vote) k.cdc.MustUnmarshalBinaryBare(iterator.Value(), &vote)
if cb(vote) { if cb(vote) {
break break