Skip to content

Commit d32aa4f

Browse files
committed
Transfer Z's changes from z/update-state-change-entry-encoder branch to pos
1 parent 7283bbe commit d32aa4f

File tree

99 files changed

+475
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+475
-296
lines changed

entries/access_group.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func AccessGroupEncoderToPGStruct(accessGroupEntry *lib.AccessGroupEntry, keyByt
5252

5353
// PostBatchOperation is the entry point for processing a batch of post entries. It determines the appropriate handler
5454
// based on the operation type and executes it.
55-
func AccessGroupBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
55+
func AccessGroupBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
5656
// We check before we call this function that there is at least one operation type.
5757
// We also ensure before this that all entries have the same operation type.
5858
operationType := entries[0].OperationType
@@ -69,7 +69,7 @@ func AccessGroupBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, para
6969
}
7070

7171
// bulkInsertAccessGroupEntry inserts a batch of access_group entries into the database.
72-
func bulkInsertAccessGroupEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
72+
func bulkInsertAccessGroupEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
7373
// Track the unique entries we've inserted so we don't insert the same entry twice.
7474
uniqueEntries := consumer.UniqueEntries(entries)
7575
// Create a new array to hold the bun struct.
@@ -94,7 +94,7 @@ func bulkInsertAccessGroupEntry(entries []*lib.StateChangeEntry, db *bun.DB, ope
9494
}
9595

9696
// bulkDeletePostEntry deletes a batch of access_group entries from the database.
97-
func bulkDeleteAccessGroupEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
97+
func bulkDeleteAccessGroupEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
9898
// Track the unique entries we've inserted so we don't insert the same entry twice.
9999
uniqueEntries := consumer.UniqueEntries(entries)
100100

entries/access_group_member.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func AccessGroupMemberEncoderToPGStruct(accessGroupMemberEntry *lib.AccessGroupM
5757

5858
// PostBatchOperation is the entry point for processing a batch of post entries. It determines the appropriate handler
5959
// based on the operation type and executes it.
60-
func AccessGroupMemberBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
60+
func AccessGroupMemberBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
6161
// We check before we call this function that there is at least one operation type.
6262
// We also ensure before this that all entries have the same operation type.
6363
operationType := entries[0].OperationType
@@ -74,7 +74,7 @@ func AccessGroupMemberBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB
7474
}
7575

7676
// bulkInsertAccessGroupMemberEntry inserts a batch of access_group_member entries into the database.
77-
func bulkInsertAccessGroupMemberEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
77+
func bulkInsertAccessGroupMemberEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
7878
// Track the unique entries we've inserted so we don't insert the same entry twice.
7979
uniqueEntries := consumer.UniqueEntries(entries)
8080
// Create a new array to hold the bun struct.
@@ -99,7 +99,7 @@ func bulkInsertAccessGroupMemberEntry(entries []*lib.StateChangeEntry, db *bun.D
9999
}
100100

101101
// bulkDeletePostEntry deletes a batch of access_group_member entries from the database.
102-
func bulkDeleteAccessGroupMemberEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
102+
func bulkDeleteAccessGroupMemberEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
103103
// Track the unique entries we've inserted so we don't insert the same entry twice.
104104
uniqueEntries := consumer.UniqueEntries(entries)
105105

entries/balance.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func BalanceEntryEncoderToPGStruct(balanceEntry *lib.BalanceEntry, keyBytes []by
4646

4747
// PostBatchOperation is the entry point for processing a batch of post entries. It determines the appropriate handler
4848
// based on the operation type and executes it.
49-
func BalanceBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
49+
func BalanceBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
5050
// We check before we call this function that there is at least one operation type.
5151
// We also ensure before this that all entries have the same operation type.
5252
operationType := entries[0].OperationType
@@ -63,7 +63,7 @@ func BalanceBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *
6363
}
6464

6565
// bulkInsertBalanceEntry inserts a batch of balance entries into the database.
66-
func bulkInsertBalanceEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
66+
func bulkInsertBalanceEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
6767
// Track the unique entries we've inserted so we don't insert the same entry twice.
6868
uniqueEntries := consumer.UniqueEntries(entries)
6969
// Create a new array to hold the bun struct.
@@ -88,7 +88,7 @@ func bulkInsertBalanceEntry(entries []*lib.StateChangeEntry, db *bun.DB, operati
8888
}
8989

9090
// bulkDeletePostEntry deletes a batch of balance entries from the database.
91-
func bulkDeleteBalanceEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
91+
func bulkDeleteBalanceEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
9292
// Track the unique entries we've inserted so we don't insert the same entry twice.
9393
uniqueEntries := consumer.UniqueEntries(entries)
9494

entries/block.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func BlockEncoderToPGStruct(block *lib.MsgDeSoBlock, keyBytes []byte, params *li
9090

9191
// PostBatchOperation is the entry point for processing a batch of post entries. It determines the appropriate handler
9292
// based on the operation type and executes it.
93-
func BlockBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
93+
func BlockBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
9494
// We check before we call this function that there is at least one operation type.
9595
// We also ensure before this that all entries have the same operation type.
9696
operationType := entries[0].OperationType
@@ -107,7 +107,7 @@ func BlockBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *li
107107
}
108108

109109
// bulkInsertUtxoOperationsEntry inserts a batch of user_association entries into the database.
110-
func bulkInsertBlockEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
110+
func bulkInsertBlockEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
111111
// If this block is a part of the initial sync, skip it - it will be handled by the utxo operations.
112112
if operationType == lib.DbOperationTypeInsert {
113113
return nil
@@ -217,7 +217,7 @@ func bulkInsertBlockEntry(entries []*lib.StateChangeEntry, db *bun.DB, operation
217217
}
218218

219219
// bulkDeleteBlockEntry deletes a batch of block entries from the database.
220-
func bulkDeleteBlockEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
220+
func bulkDeleteBlockEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
221221
// Track the unique entries we've inserted so we don't insert the same entry twice.
222222
uniqueEntries := consumer.UniqueEntries(entries)
223223

@@ -229,7 +229,7 @@ func bulkDeleteBlockEntry(entries []*lib.StateChangeEntry, db *bun.DB, operation
229229

230230
// bulkDeleteBlockEntriesFromKeysToDelete deletes a batch of block entries from the database.
231231
// It also deletes any transactions and utxo operations associated with the block.
232-
func bulkDeleteBlockEntriesFromKeysToDelete(db *bun.DB, keysToDelete [][]byte) error {
232+
func bulkDeleteBlockEntriesFromKeysToDelete(db bun.IDB, keysToDelete [][]byte) error {
233233
// Execute the delete query on the blocks table.
234234
if _, err := db.NewDelete().
235235
Model(&PGBlockEntry{}).

entries/bls_pkid_pair.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func BLSPublicKeyPKIDPairSnapshotEncoderToPGStruct(
7777

7878
// BLSPublicKeyPKIDPairBatchOperation is the entry point for processing a batch of BLSPublicKeyPKIDPair entries.
7979
// It determines the appropriate handler based on the operation type and executes it.
80-
func BLSPublicKeyPKIDPairBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
80+
func BLSPublicKeyPKIDPairBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
8181
// We check before we call this function that there is at least one operation type.
8282
// We also ensure before this that all entries have the same operation type.
8383
operationType := entries[0].OperationType
@@ -95,7 +95,7 @@ func BLSPublicKeyPKIDPairBatchOperation(entries []*lib.StateChangeEntry, db *bun
9595

9696
// bulkInsertBLSPkidPairEntry inserts a batch of stake entries into the database.
9797
func bulkInsertBLSPkidPairEntry(
98-
entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams,
98+
entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams,
9999
) error {
100100
// Track the unique entries we've inserted so we don't insert the same entry twice.
101101
uniqueEntries := consumer.UniqueEntries(entries)
@@ -149,7 +149,7 @@ func bulkInsertBLSPkidPairEntry(
149149
}
150150

151151
// bulkDeleteBLSPkidPairEntry deletes a batch of stake entries from the database.
152-
func bulkDeleteBLSPkidPairEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
152+
func bulkDeleteBLSPkidPairEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
153153
// Track the unique entries we've inserted so we don't insert the same entry twice.
154154
uniqueEntries := consumer.UniqueEntries(entries)
155155

entries/dao_coin_limit_order.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func DaoCoinLimitOrderEncoderToPGStruct(daoCoinLimitOrder *lib.DAOCoinLimitOrder
4848

4949
// DaoCoinLimitOrderBatchOperation is the entry point for processing a batch of post entries. It determines the appropriate handler
5050
// based on the operation type and executes it.
51-
func DaoCoinLimitOrderBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
51+
func DaoCoinLimitOrderBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
5252
// We check before we call this function that there is at least one operation type.
5353
// We also ensure before this that all entries have the same operation type.
5454
operationType := entries[0].OperationType
@@ -65,7 +65,7 @@ func DaoCoinLimitOrderBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB
6565
}
6666

6767
// bulkInsertDaoCoinLimitOrderEntry inserts a batch of post_association entries into the database.
68-
func bulkInsertDaoCoinLimitOrderEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
68+
func bulkInsertDaoCoinLimitOrderEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
6969
// Track the unique entries we've inserted so we don't insert the same entry twice.
7070
uniqueEntries := consumer.UniqueEntries(entries)
7171
// Create a new array to hold the bun struct.
@@ -89,7 +89,7 @@ func bulkInsertDaoCoinLimitOrderEntry(entries []*lib.StateChangeEntry, db *bun.D
8989
}
9090

9191
// bulkDeletePostEntry deletes a batch of post_association entries from the database.
92-
func bulkDeleteDaoCoinLimitOrderEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
92+
func bulkDeleteDaoCoinLimitOrderEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
9393
// Track the unique entries we've inserted so we don't insert the same entry twice.
9494
uniqueEntries := consumer.UniqueEntries(entries)
9595

entries/derived_key.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func DerivedKeyEncoderToPGStruct(derivedKeyEntry *lib.DerivedKeyEntry, keyBytes
5656

5757
// PostBatchOperation is the entry point for processing a batch of post entries. It determines the appropriate handler
5858
// based on the operation type and executes it.
59-
func DerivedKeyBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
59+
func DerivedKeyBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
6060
// We check before we call this function that there is at least one operation type.
6161
// We also ensure before this that all entries have the same operation type.
6262
operationType := entries[0].OperationType
@@ -73,7 +73,7 @@ func DerivedKeyBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, param
7373
}
7474

7575
// bulkInsertDerivedKeyEntry inserts a batch of derived_key entries into the database.
76-
func bulkInsertDerivedKeyEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
76+
func bulkInsertDerivedKeyEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
7777
// Track the unique entries we've inserted so we don't insert the same entry twice.
7878
uniqueEntries := consumer.UniqueEntries(entries)
7979
// Create a new array to hold the bun struct.
@@ -101,7 +101,7 @@ func bulkInsertDerivedKeyEntry(entries []*lib.StateChangeEntry, db *bun.DB, oper
101101
}
102102

103103
// bulkDeletePostEntry deletes a batch of derived_key entries from the database.
104-
func bulkDeleteDerivedKeyEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
104+
func bulkDeleteDerivedKeyEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
105105
// Track the unique entries we've inserted so we don't insert the same entry twice.
106106
uniqueEntries := consumer.UniqueEntries(entries)
107107

entries/deso_balance.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func DesoBalanceEncoderToPGStruct(desoBalanceEntry *lib.DeSoBalanceEntry, keyByt
3636

3737
// PostBatchOperation is the entry point for processing a batch of post entries. It determines the appropriate handler
3838
// based on the operation type and executes it.
39-
func DesoBalanceBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
39+
func DesoBalanceBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
4040
// We check before we call this function that there is at least one operation type.
4141
// We also ensure before this that all entries have the same operation type.
4242
operationType := entries[0].OperationType
@@ -53,7 +53,7 @@ func DesoBalanceBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, para
5353
}
5454

5555
// bulkInsertDiamondEntry inserts a batch of diamond entries into the database.
56-
func bulkInsertDesoBalanceEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
56+
func bulkInsertDesoBalanceEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
5757
// Track the unique entries we've inserted so we don't insert the same entry twice.
5858
uniqueEntries := consumer.UniqueEntries(entries)
5959
// Create a new array to hold the bun struct.
@@ -77,7 +77,7 @@ func bulkInsertDesoBalanceEntry(entries []*lib.StateChangeEntry, db *bun.DB, ope
7777
}
7878

7979
// bulkDeletePostEntry deletes a batch of diamond entries from the database.
80-
func bulkDeleteDesoBalanceEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
80+
func bulkDeleteDesoBalanceEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
8181
// Track the unique entries we've inserted so we don't insert the same entry twice.
8282
uniqueEntries := consumer.UniqueEntries(entries)
8383

entries/diamond.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func DiamondEncoderToPGStruct(diamondEntry *lib.DiamondEntry, keyBytes []byte, p
4141

4242
// PostBatchOperation is the entry point for processing a batch of post entries. It determines the appropriate handler
4343
// based on the operation type and executes it.
44-
func DiamondBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
44+
func DiamondBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
4545
// We check before we call this function that there is at least one operation type.
4646
// We also ensure before this that all entries have the same operation type.
4747
operationType := entries[0].OperationType
@@ -58,7 +58,7 @@ func DiamondBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *
5858
}
5959

6060
// bulkInsertDiamondEntry inserts a batch of diamond entries into the database.
61-
func bulkInsertDiamondEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
61+
func bulkInsertDiamondEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
6262
// Track the unique entries we've inserted so we don't insert the same entry twice.
6363
uniqueEntries := consumer.UniqueEntries(entries)
6464
// Create a new array to hold the bun struct.
@@ -82,7 +82,7 @@ func bulkInsertDiamondEntry(entries []*lib.StateChangeEntry, db *bun.DB, operati
8282
}
8383

8484
// bulkDeletePostEntry deletes a batch of diamond entries from the database.
85-
func bulkDeleteDiamondEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType) error {
85+
func bulkDeleteDiamondEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType) error {
8686
// Track the unique entries we've inserted so we don't insert the same entry twice.
8787
uniqueEntries := consumer.UniqueEntries(entries)
8888

entries/epoch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func EpochEntryEncoderToPGStruct(epochEntry *lib.EpochEntry, keyBytes []byte, pa
5353

5454
// EpochEntryBatchOperation is the entry point for processing a batch of Epoch entries.
5555
// It determines the appropriate handler based on the operation type and executes it.
56-
func EpochEntryBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, params *lib.DeSoParams) error {
56+
func EpochEntryBatchOperation(entries []*lib.StateChangeEntry, db bun.IDB, params *lib.DeSoParams) error {
5757
// We check before we call this function that there is at least one operation type.
5858
// We also ensure before this that all entries have the same operation type.
5959
operationType := entries[0].OperationType
@@ -73,7 +73,7 @@ func EpochEntryBatchOperation(entries []*lib.StateChangeEntry, db *bun.DB, param
7373
}
7474

7575
// bulkInsertEpochEntry inserts a batch of locked stake entries into the database.
76-
func bulkInsertEpochEntry(entries []*lib.StateChangeEntry, db *bun.DB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
76+
func bulkInsertEpochEntry(entries []*lib.StateChangeEntry, db bun.IDB, operationType lib.StateSyncerOperationType, params *lib.DeSoParams) error {
7777
// Track the unique entries we've inserted so we don't insert the same entry twice.
7878
uniqueEntries := consumer.UniqueEntries(entries)
7979
// Create a new array to hold the bun struct.

0 commit comments

Comments
 (0)