@@ -26,40 +26,47 @@ where
2626 fn visit_args_task ( & mut self , task : & ArgsTask ) {
2727 match self . context {
2828 PersistorContext :: PersistStrategy { uses_lookup_tables } => {
29- let commit_strategy = if uses_lookup_tables {
30- CommitStrategy :: StateArgsWithLookupTable
31- } else {
32- CommitStrategy :: StateArgs
33- } ;
34-
35- match & task. task_type {
36- ArgsTaskType :: Commit ( task) => {
37- if let Err ( err) = self . persistor . set_commit_strategy (
38- task. commit_id ,
39- & task. committed_account . pubkey ,
40- commit_strategy,
41- ) {
42- error ! (
43- "Failed to persist commit strategy {}: {}" ,
44- commit_strategy. as_str( ) ,
45- err
46- ) ;
29+ let commit_strategy = |is_diff : bool | {
30+ if is_diff {
31+ if uses_lookup_tables {
32+ CommitStrategy :: DiffArgsWithLookupTable
33+ } else {
34+ CommitStrategy :: DiffArgs
4735 }
48- }
49- ArgsTaskType :: CommitDiff ( task) => {
50- if let Err ( err) = self . persistor . set_commit_strategy (
51- task. commit_id ,
52- & task. committed_account . pubkey ,
53- commit_strategy,
54- ) {
55- error ! (
56- "Failed to persist commit strategy {}: {}" ,
57- commit_strategy. as_str( ) ,
58- err
59- ) ;
36+ } else {
37+ if uses_lookup_tables {
38+ CommitStrategy :: StateArgsWithLookupTable
39+ } else {
40+ CommitStrategy :: StateArgs
6041 }
6142 }
62- _ => { }
43+ } ;
44+
45+ let ( commit_id, pubkey, commit_strategy) = match & task. task_type
46+ {
47+ ArgsTaskType :: Commit ( task) => (
48+ task. commit_id ,
49+ & task. committed_account . pubkey ,
50+ commit_strategy ( false ) ,
51+ ) ,
52+ ArgsTaskType :: CommitDiff ( task) => (
53+ task. commit_id ,
54+ & task. committed_account . pubkey ,
55+ commit_strategy ( true ) ,
56+ ) ,
57+ _ => return ,
58+ } ;
59+
60+ if let Err ( err) = self . persistor . set_commit_strategy (
61+ commit_id,
62+ & pubkey,
63+ commit_strategy,
64+ ) {
65+ error ! (
66+ "Failed to persist commit strategy {}: {}" ,
67+ commit_strategy. as_str( ) ,
68+ err
69+ ) ;
6370 }
6471 }
6572 }
@@ -68,39 +75,46 @@ where
6875 fn visit_buffer_task ( & mut self , task : & BufferTask ) {
6976 match self . context {
7077 PersistorContext :: PersistStrategy { uses_lookup_tables } => {
71- let commit_strategy = if uses_lookup_tables {
72- CommitStrategy :: StateBufferWithLookupTable
73- } else {
74- CommitStrategy :: StateBuffer
75- } ;
76-
77- match & task. task_type {
78- BufferTaskType :: Commit ( task) => {
79- if let Err ( err) = self . persistor . set_commit_strategy (
80- task. commit_id ,
81- & task. committed_account . pubkey ,
82- commit_strategy,
83- ) {
84- error ! (
85- "Failed to persist commit strategy {}: {}" ,
86- commit_strategy. as_str( ) ,
87- err
88- ) ;
78+ let commit_strategy = |is_diff : bool | {
79+ if is_diff {
80+ if uses_lookup_tables {
81+ CommitStrategy :: DiffBufferWithLookupTable
82+ } else {
83+ CommitStrategy :: DiffBuffer
8984 }
90- }
91- BufferTaskType :: CommitDiff ( task) => {
92- if let Err ( err) = self . persistor . set_commit_strategy (
93- task. commit_id ,
94- & task. committed_account . pubkey ,
95- commit_strategy,
96- ) {
97- error ! (
98- "Failed to persist commit strategy {}: {}" ,
99- commit_strategy. as_str( ) ,
100- err
101- ) ;
85+ } else {
86+ if uses_lookup_tables {
87+ CommitStrategy :: StateBufferWithLookupTable
88+ } else {
89+ CommitStrategy :: StateBuffer
10290 }
10391 }
92+ } ;
93+
94+ let ( commit_id, pubkey, commit_strategy) = match & task. task_type
95+ {
96+ BufferTaskType :: Commit ( task) => (
97+ task. commit_id ,
98+ & task. committed_account . pubkey ,
99+ commit_strategy ( false ) ,
100+ ) ,
101+ BufferTaskType :: CommitDiff ( task) => (
102+ task. commit_id ,
103+ & task. committed_account . pubkey ,
104+ commit_strategy ( true ) ,
105+ ) ,
106+ } ;
107+
108+ if let Err ( err) = self . persistor . set_commit_strategy (
109+ commit_id,
110+ & pubkey,
111+ commit_strategy,
112+ ) {
113+ error ! (
114+ "Failed to persist commit strategy {}: {}" ,
115+ commit_strategy. as_str( ) ,
116+ err
117+ ) ;
104118 }
105119 }
106120 }
0 commit comments