@@ -42,9 +42,16 @@ type NewPrivacyMapDB func(groupID session.ID) PrivacyMapDB
4242// PrivacyDB constructs a PrivacyMapDB that will be indexed under the given 
4343// group ID key. 
4444func  (db  * DB ) PrivacyDB (groupID  session.ID ) PrivacyMapDB  {
45- 	return  & privacyMapDB {
46- 		db :      db ,
47- 		groupID : groupID ,
45+ 	return  & kvdbExecutor [PrivacyMapTx ]{
46+ 		db : db .DB ,
47+ 		wrapTx : func (tx  * bbolt.Tx ) PrivacyMapTx  {
48+ 			return  & privacyMapTx {
49+ 				boltTx : tx ,
50+ 				privacyMapDB : & privacyMapDB {
51+ 					groupID : groupID ,
52+ 				},
53+ 			}
54+ 		},
4855	}
4956}
5057
@@ -74,50 +81,9 @@ type PrivacyMapTx interface {
7481
7582// privacyMapDB is an implementation of PrivacyMapDB. 
7683type  privacyMapDB  struct  {
77- 	db       * DB 
7884	groupID  session.ID 
7985}
8086
81- // Update opens a database read/write transaction and executes the function f 
82- // with the transaction passed as a parameter. After f exits, if f did not 
83- // error, the transaction is committed. Otherwise, if f did error, the 
84- // transaction is rolled back. If the rollback fails, the original error 
85- // returned by f is still returned. If the commit fails, the commit error is 
86- // returned. 
87- // 
88- // NOTE: this is part of the PrivacyMapDB interface. 
89- func  (p  * privacyMapDB ) Update (ctx  context.Context , fn  func (ctx  context.Context ,
90- 	tx  PrivacyMapTx ) error ) error  {
91- 
92- 	return  p .db .Update (func (tx  * bbolt.Tx ) error  {
93- 		boltTx  :=  & privacyMapTx {
94- 			privacyMapDB : p ,
95- 			boltTx :       tx ,
96- 		}
97- 
98- 		return  fn (ctx , boltTx )
99- 	})
100- }
101- 
102- // View opens a database read transaction and executes the function f with the 
103- // transaction passed as a parameter. After f exits, the transaction is rolled 
104- // back. If f errors, its error is returned, not a rollback error (if any 
105- // occur). 
106- // 
107- // NOTE: this is part of the PrivacyMapDB interface. 
108- func  (p  * privacyMapDB ) View (ctx  context.Context , fn  func (ctx  context.Context ,
109- 	tx  PrivacyMapTx ) error ) error  {
110- 
111- 	return  p .db .View (func (tx  * bbolt.Tx ) error  {
112- 		boltTx  :=  & privacyMapTx {
113- 			privacyMapDB : p ,
114- 			boltTx :       tx ,
115- 		}
116- 
117- 		return  fn (ctx , boltTx )
118- 	})
119- }
120- 
12187// privacyMapTx is an implementation of PrivacyMapTx. 
12288type  privacyMapTx  struct  {
12389	* privacyMapDB 
0 commit comments