Map entry txs to serialized txs in blockstream

This commit is contained in:
Tyera Eulberg 2019-03-29 00:10:32 -06:00 committed by Tyera Eulberg
parent 10239c3b3c
commit 4776dc36ab
1 changed files with 13 additions and 1 deletions

View File

@ -4,7 +4,9 @@
use crate::entry::Entry;
use crate::result::Result;
use bincode::serialize;
use chrono::{SecondsFormat, Utc};
use serde_json::json;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use std::cell::RefCell;
@ -91,7 +93,17 @@ where
leader_id: &Pubkey,
entry: &Entry,
) -> Result<()> {
let json_entry = serde_json::to_string(&entry)?;
let transactions: Vec<Vec<u8>> = entry
.transactions
.iter()
.map(|tx| serialize(&tx).unwrap())
.collect();
let stream_entry = json!({
"num_hashes": entry.num_hashes,
"hash": entry.hash,
"transactions": transactions
});
let json_entry = serde_json::to_string(&stream_entry)?;
let payload = format!(
r#"{{"dt":"{}","t":"entry","s":{},"h":{},"l":"{:?}","entry":{}}}"#,
Utc::now().to_rfc3339_opts(SecondsFormat::Nanos, true),