Skip to content

Commit 18c4ceb

Browse files
committed
address feedback, meta should also handle chain accordingly
1 parent 515a153 commit 18c4ceb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/cache.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ impl BlockchainDb {
130130
#[derive(Clone, Debug, Default, Eq, Serialize)]
131131
pub struct BlockchainDbMeta {
132132
/// The chain of the blockchain of the block environment
133+
#[serde(skip_serializing_if = "Option::is_none")]
133134
pub chain: Option<Chain>,
134135
/// The block environment
135136
pub block_env: BlockEnv,
@@ -250,6 +251,7 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta {
250251
// custom deserialize impl to not break existing cache files
251252
#[derive(Deserialize)]
252253
struct Meta {
254+
chain: Option<Chain>,
253255
block_env: BlockEnvBackwardsCompat,
254256
/// all the hosts used to connect to
255257
#[serde(alias = "host")]
@@ -263,9 +265,9 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta {
263265
Single(String),
264266
}
265267

266-
let Meta { block_env, hosts } = Meta::deserialize(deserializer)?;
268+
let Meta { chain, block_env, hosts } = Meta::deserialize(deserializer)?;
267269
Ok(Self {
268-
chain: None,
270+
chain,
269271
block_env: block_env.inner,
270272
hosts: match hosts {
271273
Hosts::Multi(hosts) => hosts,

0 commit comments

Comments
 (0)