Remove BeginBlock

This commit is contained in:
Jae Kwon 2016-03-06 17:57:47 -08:00
parent 36c25f242f
commit 61c34ade0d
7 changed files with 59 additions and 92 deletions

View File

@ -73,13 +73,9 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil
* __Usage__:<br/> * __Usage__:<br/>
Called once upon genesis Called once upon genesis
#### BeginBlock
* __Arguments__:
* `Height (uint64)`: Block number
* __Usage__:<br/>
Signals the beginning of a block
#### EndBlock #### EndBlock
* __Arguments__:
* `Height (uint64)`: The block height that ended
* __Returns__: * __Returns__:
* `Validators ([]Validator)`: Changed validators with new voting powers (0 to remove) * `Validators ([]Validator)`: Changed validators with new voting powers (0 to remove)
* __Usage__:<br/> * __Usage__:<br/>
@ -87,9 +83,9 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil
## Changelog ## Changelog
### Feb 28th, 2016 ### Mar 6th, 2016
* Added InitChain, BeginBlock, EndBlock * Added InitChain, EndBlock
### Feb 14th, 2016 ### Feb 14th, 2016

View File

@ -219,12 +219,8 @@ func (cli *Client) InitChainAsync(validators []*types.Validator) *ReqRes {
return cli.queueRequest(types.RequestInitChain(validators)) return cli.queueRequest(types.RequestInitChain(validators))
} }
func (cli *Client) BeginBlockAsync(height uint64) *ReqRes { func (cli *Client) EndBlockAsync(height uint64) *ReqRes {
return cli.queueRequest(types.RequestBeginBlock(height)) return cli.queueRequest(types.RequestEndBlock(height))
}
func (cli *Client) EndBlockAsync() *ReqRes {
return cli.queueRequest(types.RequestEndBlock())
} }
//---------------------------------------- //----------------------------------------
@ -301,17 +297,8 @@ func (cli *Client) InitChainSync(validators []*types.Validator) (err error) {
return nil return nil
} }
func (cli *Client) BeginBlockSync(height uint64) (err error) { func (cli *Client) EndBlockSync(height uint64) (validators []*types.Validator, err error) {
cli.queueRequest(types.RequestBeginBlock(height)) reqres := cli.queueRequest(types.RequestEndBlock(height))
cli.FlushSync()
if cli.err != nil {
return cli.err
}
return nil
}
func (cli *Client) EndBlockSync() (validators []*types.Validator, err error) {
reqres := cli.queueRequest(types.RequestEndBlock())
cli.FlushSync() cli.FlushSync()
if cli.err != nil { if cli.err != nil {
return nil, cli.err return nil, cli.err

View File

@ -157,7 +157,7 @@ func (s *Server) handleRequest(req *types.Request, responses chan<- *types.Respo
} }
case types.MessageType_EndBlock: case types.MessageType_EndBlock:
if app, ok := s.app.(types.BlockchainAware); ok { if app, ok := s.app.(types.BlockchainAware); ok {
validators := app.EndBlock() validators := app.EndBlock(req.Height)
responses <- types.ResponseEndBlock(validators) responses <- types.ResponseEndBlock(validators)
} else { } else {
responses <- types.ResponseEndBlock(nil) responses <- types.ResponseEndBlock(nil)

View File

@ -29,10 +29,7 @@ type BlockchainAware interface {
// validators: genesis validators from TendermintCore // validators: genesis validators from TendermintCore
InitChain(validators []*Validator) InitChain(validators []*Validator)
// Signals the beginning of a block
BeginBlock(height uint64)
// Signals the end of a block // Signals the end of a block
// validators: changed validators from app to TendermintCore // validators: changed validators from app to TendermintCore
EndBlock() (validators []*Validator) EndBlock(height uint64) (validators []*Validator)
} }

View File

@ -68,19 +68,13 @@ func RequestInitChain(validators []*Validator) *Request {
} }
} }
func RequestBeginBlock(height uint64) *Request { func RequestEndBlock(height uint64) *Request {
return &Request{ return &Request{
Type: MessageType_BeginBlock, Type: MessageType_EndBlock,
Height: height, Height: height,
} }
} }
func RequestEndBlock() *Request {
return &Request{
Type: MessageType_EndBlock,
}
}
//---------------------------------------- //----------------------------------------
func ResponseException(errStr string) *Response { func ResponseException(errStr string) *Response {
@ -158,12 +152,6 @@ func ResponseInitChain() *Response {
} }
} }
func ResponseBeginBlock() *Response {
return &Response{
Type: MessageType_BeginBlock,
}
}
func ResponseEndBlock(validators []*Validator) *Response { func ResponseEndBlock(validators []*Validator) *Response {
return &Response{ return &Response{
Type: MessageType_EndBlock, Type: MessageType_EndBlock,

View File

@ -38,8 +38,8 @@ const (
MessageType_Commit MessageType = 19 MessageType_Commit MessageType = 19
MessageType_Query MessageType = 20 MessageType_Query MessageType = 20
MessageType_InitChain MessageType = 21 MessageType_InitChain MessageType = 21
MessageType_BeginBlock MessageType = 22 // BeginBlock = 0x16; NOT USED
MessageType_EndBlock MessageType = 23 MessageType_EndBlock MessageType = 23
) )
var MessageType_name = map[int32]string{ var MessageType_name = map[int32]string{
@ -54,7 +54,6 @@ var MessageType_name = map[int32]string{
19: "Commit", 19: "Commit",
20: "Query", 20: "Query",
21: "InitChain", 21: "InitChain",
22: "BeginBlock",
23: "EndBlock", 23: "EndBlock",
} }
var MessageType_value = map[string]int32{ var MessageType_value = map[string]int32{
@ -69,7 +68,6 @@ var MessageType_value = map[string]int32{
"Commit": 19, "Commit": 19,
"Query": 20, "Query": 20,
"InitChain": 21, "InitChain": 21,
"BeginBlock": 22,
"EndBlock": 23, "EndBlock": 23,
} }
@ -81,7 +79,8 @@ func (MessageType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []
type CodeType int32 type CodeType int32
const ( const (
CodeType_OK CodeType = 0 CodeType_OK CodeType = 0
// General response codes, 0 ~ 99
CodeType_InternalError CodeType = 1 CodeType_InternalError CodeType = 1
CodeType_EncodingError CodeType = 2 CodeType_EncodingError CodeType = 2
CodeType_BadNonce CodeType = 3 CodeType_BadNonce CodeType = 3
@ -225,46 +224,46 @@ func init() {
} }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 654 bytes of a gzipped FileDescriptorProto // 649 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x4f, 0xdb, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x54, 0xcb, 0x52, 0xdb, 0x4a,
0x10, 0xad, 0x13, 0x27, 0x24, 0x13, 0x08, 0x9b, 0x6d, 0x02, 0x69, 0x4f, 0x88, 0x4a, 0x15, 0xe2, 0x10, 0xbd, 0x63, 0xcb, 0xc6, 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6, 0x98, 0x2f, 0xd0, 0x73, 0x35, 0x96, 0xe3, 0x3f, 0x33, 0x0a, 0xd6, 0x9e, 0x2f, 0x14, 0x02, 0x5f, 0xee, 0x5d,
0x64, 0x02, 0xdf, 0xef, 0x5c, 0xc8, 0x25, 0x7e, 0x58, 0x94, 0xad, 0x39, 0x5f, 0x98, 0x89, 0xfc, 0x28, 0x25, 0xbe, 0x32, 0xca, 0xd6, 0x99, 0x2f, 0xcc, 0x44, 0xbe, 0x4d, 0x4d, 0xcd, 0x4a, 0xe7,
0x9c, 0x9a, 0x9a, 0x95, 0xce, 0x94, 0x46, 0xf6, 0xcb, 0xe2, 0x0f, 0xa1, 0x45, 0x74, 0x5f, 0xa6, 0x4a, 0x23, 0xff, 0xce, 0xc4, 0x7f, 0xd0, 0x25, 0x7a, 0x20, 0xf3, 0x57, 0x4e, 0x24, 0x2d, 0xfa,
0xaf, 0x9e, 0x48, 0x5a, 0xf4, 0xb1, 0x79, 0xc0, 0xec, 0xb7, 0x75, 0x5e, 0x4e, 0xff, 0x8e, 0x9e, 0xc4, 0x3c, 0x58, 0xfe, 0x83, 0x5d, 0xd4, 0xf3, 0xbf, 0x9f, 0xc7, 0x3f, 0x03, 0x00, 0x00, 0xff,
0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0xa9, 0x69, 0x85, 0x09, 0xa3, 0x04, 0x00, 0x00, 0xff, 0x7f, 0x32, 0xc0, 0xd9, 0x93, 0x04, 0x00, 0x00,
} }

View File

@ -19,7 +19,7 @@ enum MessageType {
Commit = 0x13; Commit = 0x13;
Query = 0x14; Query = 0x14;
InitChain = 0x15; InitChain = 0x15;
BeginBlock = 0x16; // BeginBlock = 0x16; NOT USED
EndBlock = 0x17; EndBlock = 0x17;
} }