Separated out certifiers.Commit from rpc structs

This commit is contained in:
Ethan Frey
2017-10-25 16:43:18 +02:00
parent 0396b6d521
commit f653ba63bf
10 changed files with 59 additions and 39 deletions
+3 -3
View File
@@ -280,7 +280,7 @@ func Commit(heightPtr *int) (*ctypes.ResultCommit, error) {
height := blockStore.Height()
header := blockStore.LoadBlockMeta(height).Header
commit := blockStore.LoadSeenCommit(height)
return &ctypes.ResultCommit{header, commit, false}, nil
return ctypes.NewResultCommit(header, commit, false), nil
}
height := *heightPtr
@@ -298,10 +298,10 @@ func Commit(heightPtr *int) (*ctypes.ResultCommit, error) {
// use a non-canonical commit
if height == storeHeight {
commit := blockStore.LoadSeenCommit(height)
return &ctypes.ResultCommit{header, commit, false}, nil
return ctypes.NewResultCommit(header, commit, false), nil
}
// Return the canonical commit (comes from the block at height+1)
commit := blockStore.LoadBlockCommit(height)
return &ctypes.ResultCommit{header, commit, true}, nil
return ctypes.NewResultCommit(header, commit, true), nil
}
+18 -3
View File
@@ -26,9 +26,24 @@ type ResultBlock struct {
}
type ResultCommit struct {
Header *types.Header `json:"header"`
Commit *types.Commit `json:"commit"`
CanonicalCommit bool `json:"canonical"`
// SignedHeader is header and commit, embedded so we only have
// one level in the json output
types.SignedHeader
CanonicalCommit bool `json:"canonical"`
}
// NewResultCommit is a helper to initialize the ResultCommit with
// the embedded struct
func NewResultCommit(header *types.Header, commit *types.Commit,
canonical bool) *ResultCommit {
return &ResultCommit{
SignedHeader: types.SignedHeader{
Header: header,
Commit: commit,
},
CanonicalCommit: canonical,
}
}
type ResultStatus struct {