File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
chainstate/storage/src/internal Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -51,22 +51,25 @@ pub struct Store<B: storage::Backend>(storage::Storage<B, Schema>);
5151impl < B : storage:: Backend > Store < B > {
5252 /// Create a new chainstate storage
5353 pub fn new ( backend : B , chain_config : & ChainConfig ) -> crate :: Result < Self > {
54- let mut storage = Self :: from_backend ( backend) ?;
54+ let storage = Self :: from_backend ( backend) ?;
5555
5656 // Set defaults if missing
57+ let mut db_tx = storage. transaction_rw ( None ) ?;
5758
58- if storage . get_storage_version ( ) ?. is_none ( ) {
59- storage . set_storage_version ( ChainstateStorageVersion :: CURRENT ) ?;
59+ if db_tx . get_storage_version ( ) ?. is_none ( ) {
60+ db_tx . set_storage_version ( ChainstateStorageVersion :: CURRENT ) ?;
6061 }
6162
62- if storage . get_magic_bytes ( ) ?. is_none ( ) {
63- storage . set_magic_bytes ( chain_config. magic_bytes ( ) ) ?;
63+ if db_tx . get_magic_bytes ( ) ?. is_none ( ) {
64+ db_tx . set_magic_bytes ( chain_config. magic_bytes ( ) ) ?;
6465 }
6566
66- if storage . get_chain_type ( ) ?. is_none ( ) {
67- storage . set_chain_type ( chain_config. chain_type ( ) . name ( ) ) ?;
67+ if db_tx . get_chain_type ( ) ?. is_none ( ) {
68+ db_tx . set_chain_type ( chain_config. chain_type ( ) . name ( ) ) ?;
6869 }
6970
71+ db_tx. commit ( ) ?;
72+
7073 Ok ( storage)
7174 }
7275
You can’t perform that action at this time.
0 commit comments