1616
1717use rlp:: { Decodable , DecoderError , Encodable , Rlp , RlpStream } ;
1818
19- const ACTION_CREATE_CLIENT : u8 = 1 ;
20- const ACTION_UPDATE_CLIENT : u8 = 2 ;
19+ const DATAGRAM_CREATE_CLIENT : u8 = 1 ;
20+ const DATAGRAM_UPDATE_CLIENT : u8 = 2 ;
2121
2222#[ derive( Debug , PartialEq ) ]
23- pub enum Action {
23+ pub enum Datagram {
2424 CreateClient {
2525 id : String ,
2626 kind : u8 ,
@@ -32,58 +32,58 @@ pub enum Action {
3232 } ,
3333}
3434
35- impl Encodable for Action {
35+ impl Encodable for Datagram {
3636 fn rlp_append ( & self , s : & mut RlpStream ) {
3737 match self {
38- Action :: CreateClient {
38+ Datagram :: CreateClient {
3939 id,
4040 kind,
4141 consensus_state,
4242 } => {
43- s. begin_list ( 4 ) . append ( & ACTION_CREATE_CLIENT ) . append ( id) . append ( kind) . append ( consensus_state) ;
43+ s. begin_list ( 4 ) . append ( & DATAGRAM_CREATE_CLIENT ) . append ( id) . append ( kind) . append ( consensus_state) ;
4444 }
45- Action :: UpdateClient {
45+ Datagram :: UpdateClient {
4646 id,
4747 header,
4848 } => {
49- s. begin_list ( 3 ) . append ( & ACTION_UPDATE_CLIENT ) . append ( id) . append ( header) ;
49+ s. begin_list ( 3 ) . append ( & DATAGRAM_UPDATE_CLIENT ) . append ( id) . append ( header) ;
5050 }
5151 } ;
5252 }
5353}
5454
55- impl Decodable for Action {
55+ impl Decodable for Datagram {
5656 fn decode ( rlp : & Rlp ) -> Result < Self , DecoderError > {
5757 let tag = rlp. val_at ( 0 ) ?;
5858 match tag {
59- ACTION_CREATE_CLIENT => {
59+ DATAGRAM_CREATE_CLIENT => {
6060 let item_count = rlp. item_count ( ) ?;
6161 if item_count != 4 {
6262 return Err ( DecoderError :: RlpInvalidLength {
6363 expected : 4 ,
6464 got : item_count,
6565 } )
6666 }
67- Ok ( Action :: CreateClient {
67+ Ok ( Datagram :: CreateClient {
6868 id : rlp. val_at ( 1 ) ?,
6969 kind : rlp. val_at ( 2 ) ?,
7070 consensus_state : rlp. val_at ( 3 ) ?,
7171 } )
7272 }
73- ACTION_UPDATE_CLIENT => {
73+ DATAGRAM_UPDATE_CLIENT => {
7474 let item_count = rlp. item_count ( ) ?;
7575 if item_count != 3 {
7676 return Err ( DecoderError :: RlpInvalidLength {
7777 expected : 3 ,
7878 got : item_count,
7979 } )
8080 }
81- Ok ( Action :: UpdateClient {
81+ Ok ( Datagram :: UpdateClient {
8282 id : rlp. val_at ( 1 ) ?,
8383 header : rlp. val_at ( 2 ) ?,
8484 } )
8585 }
86- _ => Err ( DecoderError :: Custom ( "Unexpected IBC Action Type" ) ) ,
86+ _ => Err ( DecoderError :: Custom ( "Unexpected IBC Datagram Type" ) ) ,
8787 }
8888 }
8989}
0 commit comments