@@ -11,12 +11,14 @@ import (
11
11
"github.com/gogo/protobuf/proto"
12
12
gogotypes "github.com/gogo/protobuf/types"
13
13
14
+ abci "github.com/tendermint/tendermint/abci/types"
14
15
"github.com/tendermint/tendermint/crypto"
15
16
"github.com/tendermint/tendermint/crypto/merkle"
16
17
"github.com/tendermint/tendermint/libs/bits"
17
18
tmbytes "github.com/tendermint/tendermint/libs/bytes"
18
19
tmmath "github.com/tendermint/tendermint/libs/math"
19
20
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
21
+ "github.com/tendermint/tendermint/utils"
20
22
"github.com/tendermint/tendermint/version"
21
23
)
22
24
@@ -233,6 +235,30 @@ func (b *Block) ToProto() (*tmproto.Block, error) {
233
235
return pb , nil
234
236
}
235
237
238
+ func (b * Block ) ToReqBeginBlock (vals []* Validator ) abci.RequestBeginBlock {
239
+ tmHeader := b .Header .ToProto ()
240
+ votes := make ([]abci.VoteInfo , b .LastCommit .Size ())
241
+ for i , val := range vals {
242
+ commitSig := b .LastCommit .Signatures [i ]
243
+ votes [i ] = abci.VoteInfo {
244
+ Validator : TM2PB .Validator (val ),
245
+ SignedLastBlock : commitSig .BlockIDFlag != BlockIDFlagAbsent ,
246
+ }
247
+ }
248
+ abciEvidence := b .Evidence .ToABCI ()
249
+ return abci.RequestBeginBlock {
250
+ Hash : b .hash ,
251
+ Header : * tmHeader ,
252
+ LastCommitInfo : abci.LastCommitInfo {
253
+ Round : b .LastCommit .Round ,
254
+ Votes : votes ,
255
+ },
256
+ ByzantineValidators : utils .Map (abciEvidence , func (e abci.Misbehavior ) abci.Evidence {
257
+ return abci .Evidence (e )
258
+ }),
259
+ }
260
+ }
261
+
236
262
// FromProto sets a protobuf Block to the given pointer.
237
263
// It returns an error if the block is invalid.
238
264
func BlockFromProto (bp * tmproto.Block ) (* Block , error ) {
0 commit comments