Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

upgraded dependencies (tokio, bytes, protobuf) #138

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

_July 23, 2020_

## v0.7.2

### IMPROVEMENTS:

- [\#138](https://github.com/tendermint/rust-abci/pull/138): dependencies upgrades (protobuf to 2.16.2, tokio to 0.2, bytes to 0.5)

_June 30, 2020_

## v0.7.1
Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "abci"
version = "0.7.1"
version = "0.7.2"
authors = ["Adrian Brink <adrian@brink-holdings.com>", "Jackson Lewis <st.japa6@gmail.com>", "Dave Bryson", "Tomas Tauber"]
edition = "2018"
license = "MIT/Apache-2.0"
Expand All @@ -12,14 +12,15 @@ readme = "README.md"
include = ["src/**/*", "Cargo.toml"]

[dependencies]
bytes = "0.4"
protobuf = "= 2.15.1"
bytes = "0.5"
protobuf = "= 2.16.2"
byteorder = "1.3.4"
integer-encoding = "1.1.5"
log = "0.4.8"
env_logger = "0.7.1"
tokio = { version = "0.1", default-features = false, features = ["codec", "io", "tcp", "rt-full"] }
tokio = { version = "0.2", features = ["tcp", "rt-core", "io-driver", "sync"] }
tokio-util = { version = "0.3.1", features = ["codec"] }
futures = "0.3"

[build-dependencies]
protobuf-codegen-pure = "= 2.15.1"
protobuf-codegen-pure = "= 2.16.2"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Origin
version_branch = v0.33.5
version_branch = v0.33.6
tendermint = https://raw.githubusercontent.com/tendermint/tendermint/$(version_branch)

# Outputs
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To use this library to build your own ABCI apps in Rust you have to include the

```toml
[dependencies]
abci = "0.7.1"
abci = "0.7.2"
```

### Development
Expand Down Expand Up @@ -65,6 +65,7 @@ For a real life example of an ABCI application you can checkout [Cosmos SDK](htt

| Tendermint | Rust-abci |
| ---------- | :-------: |
| 0.33.6 | 0.7.2 |
| 0.33.5 | 0.7.1 |
| 0.33.1 | 0.7.0 |
| 0.32.9 | 0.6.5 |
Expand Down
40 changes: 19 additions & 21 deletions src/codec.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::error::Error;

use bytes::{BufMut, BytesMut};
use bytes::{buf::BufMutExt, BufMut, BytesMut};
use integer_encoding::VarInt;
use protobuf::Message;
use tokio::codec::{Decoder, Encoder};
use protobuf::{Message, ProtobufError};
use tokio_util::codec::{Decoder, Encoder};

use crate::messages::abci::*;

Expand All @@ -18,9 +16,9 @@ impl ABCICodec {

impl Decoder for ABCICodec {
type Item = Request;
type Error = Box<dyn Error>;
type Error = ProtobufError;

fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Request>, Box<dyn Error>> {
fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Request>, ProtobufError> {
let length = buf.len();
if length == 0 {
return Ok(None);
Expand All @@ -30,16 +28,15 @@ impl Decoder for ABCICodec {
return Ok(None);
}
let request = protobuf::parse_from_bytes(&buf[varint.1..(varint.0 as usize + varint.1)])?;
buf.split_to(varint.0 as usize + varint.1);
let _ = buf.split_to(varint.0 as usize + varint.1);
Ok(Some(request))
}
}

impl Encoder for ABCICodec {
type Item = Response;
type Error = Box<dyn Error>;
impl Encoder<Response> for ABCICodec {
type Error = ProtobufError;

fn encode(&mut self, msg: Response, buf: &mut BytesMut) -> Result<(), Box<dyn Error>> {
fn encode(&mut self, msg: Response, buf: &mut BytesMut) -> Result<(), ProtobufError> {
let msg_len = msg.compute_size();
let varint = i64::encode_var_vec(i64::from(msg_len));

Expand All @@ -49,7 +46,7 @@ impl Encoder for ABCICodec {
buf.reserve(needed);
}

buf.put(&varint);
buf.put(varint.as_ref());
msg.write_to_writer(&mut buf.writer())?;
trace!("Encode response! {:?}", &buf[..]);
Ok(())
Expand All @@ -59,9 +56,10 @@ impl Encoder for ABCICodec {
#[cfg(test)]
mod tests {
use super::*;
use std::error::Error;

fn setup_echo_request_buf() -> Result<BytesMut, Box<dyn Error>> {
let buf = &mut BytesMut::new();
let mut buf = BytesMut::new();

let mut r = Request::new();
let mut echo = RequestEcho::new();
Expand All @@ -70,16 +68,16 @@ mod tests {

let msg_len = r.compute_size();
let varint = i64::encode_var_vec(msg_len as i64);
buf.put(varint);
r.write_to_writer(&mut buf.writer())?;
buf.put(varint.as_ref());
r.write_to_writer(&mut (&mut buf).writer())?;

trace!("Encode response! {:?}", &buf[..]);

Ok(buf.take())
Ok(buf)
}

fn setup_echo_large_request_buf() -> Result<BytesMut, Box<dyn Error>> {
let buf = &mut BytesMut::new();
let mut buf = BytesMut::new();

let mut r = Request::new();
let mut echo = RequestEcho::new();
Expand All @@ -96,12 +94,12 @@ mod tests {
buf.reserve(needed);
}

buf.put(varint);
r.write_to_writer(&mut buf.writer())?;
buf.put(varint.as_ref());
r.write_to_writer(&mut (&mut buf).writer())?;

trace!("Encode response! {:?}", &buf[..]);

Ok(buf.take())
Ok(buf)
}

#[test]
Expand Down
Loading