@@ -26,40 +26,45 @@ 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- ) ;
47- }
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- ) ;
29+ let commit_strategy = |is_diff : bool | {
30+ if is_diff {
31+ if uses_lookup_tables {
32+ CommitStrategy :: DiffArgsWithLookupTable
33+ } else {
34+ CommitStrategy :: DiffArgs
6035 }
36+ } else if uses_lookup_tables {
37+ CommitStrategy :: StateArgsWithLookupTable
38+ } else {
39+ CommitStrategy :: StateArgs
6140 }
62- _ => { }
41+ } ;
42+
43+ let ( commit_id, pubkey, commit_strategy) = match & task. task_type
44+ {
45+ ArgsTaskType :: Commit ( task) => (
46+ task. commit_id ,
47+ & task. committed_account . pubkey ,
48+ commit_strategy ( false ) ,
49+ ) ,
50+ ArgsTaskType :: CommitDiff ( task) => (
51+ task. commit_id ,
52+ & task. committed_account . pubkey ,
53+ commit_strategy ( true ) ,
54+ ) ,
55+ _ => return ,
56+ } ;
57+
58+ if let Err ( err) = self . persistor . set_commit_strategy (
59+ commit_id,
60+ pubkey,
61+ commit_strategy,
62+ ) {
63+ error ! (
64+ "Failed to persist commit strategy {}: {}" ,
65+ commit_strategy. as_str( ) ,
66+ err
67+ ) ;
6368 }
6469 }
6570 }
@@ -68,39 +73,44 @@ where
6873 fn visit_buffer_task ( & mut self , task : & BufferTask ) {
6974 match self . context {
7075 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- ) ;
89- }
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- ) ;
76+ let commit_strategy = |is_diff : bool | {
77+ if is_diff {
78+ if uses_lookup_tables {
79+ CommitStrategy :: DiffBufferWithLookupTable
80+ } else {
81+ CommitStrategy :: DiffBuffer
10282 }
83+ } else if uses_lookup_tables {
84+ CommitStrategy :: StateBufferWithLookupTable
85+ } else {
86+ CommitStrategy :: StateBuffer
10387 }
88+ } ;
89+
90+ let ( commit_id, pubkey, commit_strategy) = match & task. task_type
91+ {
92+ BufferTaskType :: Commit ( task) => (
93+ task. commit_id ,
94+ & task. committed_account . pubkey ,
95+ commit_strategy ( false ) ,
96+ ) ,
97+ BufferTaskType :: CommitDiff ( task) => (
98+ task. commit_id ,
99+ & task. committed_account . pubkey ,
100+ commit_strategy ( true ) ,
101+ ) ,
102+ } ;
103+
104+ if let Err ( err) = self . persistor . set_commit_strategy (
105+ commit_id,
106+ pubkey,
107+ commit_strategy,
108+ ) {
109+ error ! (
110+ "Failed to persist commit strategy {}: {}" ,
111+ commit_strategy. as_str( ) ,
112+ err
113+ ) ;
104114 }
105115 }
106116 }
0 commit comments