Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
change field to lowercase and add ResponseEndBlockDeprecated Response…
Browse files Browse the repository at this point in the history
…BeginBlockDeprecated
  • Loading branch information
HaoyangLiu committed Nov 5, 2019
1 parent 5f8a0e2 commit 41d8dd2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
26 changes: 26 additions & 0 deletions abci/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,29 @@ func ConvertDeprecatedDeliverTxResponse(deprecated *ResponseDeliverTxDeprecated)
XXX_sizecache: deprecated.XXX_sizecache,
}
}

func ConvertDeprecatedBeginBlockResponse(deprecated *ResponseBeginBlockDeprecated) *ResponseBeginBlock {
if deprecated == nil {
return nil
}
return &ResponseBeginBlock{
Events: []Event{{Attributes: deprecated.Tags}},
XXX_NoUnkeyedLiteral: deprecated.XXX_NoUnkeyedLiteral,
XXX_unrecognized: deprecated.XXX_unrecognized,
XXX_sizecache: deprecated.XXX_sizecache,
}
}

func ConvertDeprecatedEndBlockResponse(deprecated *ResponseEndBlockDeprecated) *ResponseEndBlock {
if deprecated == nil {
return nil
}
return &ResponseEndBlock{
ValidatorUpdates: deprecated.ValidatorUpdates,
ConsensusParamUpdates: deprecated.ConsensusParamUpdates,
Events: []Event{{Attributes: deprecated.Tags}},
XXX_NoUnkeyedLiteral: deprecated.XXX_NoUnkeyedLiteral,
XXX_unrecognized: deprecated.XXX_unrecognized,
XXX_sizecache: deprecated.XXX_sizecache,
}
}
22 changes: 11 additions & 11 deletions state/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ func saveState(db dbm.DB, state State, key []byte) {
// of the various ABCI calls during block processing.
// It is persisted to disk for each height before calling Commit.
type ABCIResponses struct {
DeliverTx []*abci.ResponseDeliverTx `json:"deliver_tx"`
EndBlock *abci.ResponseEndBlock `json:"end_block"`
BeginBlock *abci.ResponseBeginBlock `json:"begin_block"`
DeliverTx []*abci.ResponseDeliverTx
EndBlock *abci.ResponseEndBlock
BeginBlock *abci.ResponseBeginBlock
}

type ABCIResponsesDeprecated struct {
DeliverTx []*abci.ResponseDeliverTxDeprecated `json:"deliver_tx"`
EndBlock *abci.ResponseEndBlock `json:"end_block"`
BeginBlock *abci.ResponseBeginBlock `json:"begin_block"`
DeliverTx []*abci.ResponseDeliverTxDeprecated
EndBlock *abci.ResponseEndBlockDeprecated
BeginBlock *abci.ResponseBeginBlockDeprecated
}

// NewABCIResponses returns a new ABCIResponses
Expand Down Expand Up @@ -185,21 +185,21 @@ func LoadABCIResponses(db dbm.DB, height int64) (*ABCIResponses, error) {
abciResponses := new(ABCIResponses)
err := cdc.UnmarshalBinaryBare(buf, abciResponses)
if err != nil {
abciResponsesDeprecated := new(ABCIResponsesDeprecated)
err := cdc.UnmarshalBinaryBare(buf, abciResponsesDeprecated)
deprecated := new(ABCIResponsesDeprecated)
err := cdc.UnmarshalBinaryBare(buf, deprecated)
if err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(fmt.Sprintf(`LoadABCIResponses: Data has been corrupted or its spec has
changed: %v\n`, err))
}
var deliverTxs []*abci.ResponseDeliverTx
for _, result := range abciResponsesDeprecated.DeliverTx {
for _, result := range deprecated.DeliverTx {
deliverTxs = append(deliverTxs, abci.ConvertDeprecatedDeliverTxResponse(result))
}
return &ABCIResponses{
DeliverTx: deliverTxs,
EndBlock: abciResponsesDeprecated.EndBlock,
BeginBlock: abciResponsesDeprecated.BeginBlock,
EndBlock: abci.ConvertDeprecatedEndBlockResponse(deprecated.EndBlock),
BeginBlock: abci.ConvertDeprecatedBeginBlockResponse(deprecated.BeginBlock),
}, nil
}
// TODO: ensure that buf is completely read.
Expand Down

0 comments on commit 41d8dd2

Please sign in to comment.