-
Notifications
You must be signed in to change notification settings - Fork 0
/
operation_participant_batch_insert_builder.go
46 lines (39 loc) · 1.36 KB
/
operation_participant_batch_insert_builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package history
import (
"context"
"github.com/shantanu-hashcash/go/support/db"
)
// OperationParticipantBatchInsertBuilder is used to insert a transaction's operations into the
// history_operations table
type OperationParticipantBatchInsertBuilder interface {
Add(
operationID int64,
accountID FutureAccountID,
) error
Exec(ctx context.Context, session db.SessionInterface) error
}
// operationParticipantBatchInsertBuilder is a simple wrapper around db.BatchInsertBuilder
type operationParticipantBatchInsertBuilder struct {
table string
builder db.FastBatchInsertBuilder
}
// NewOperationParticipantBatchInsertBuilder constructs a new OperationParticipantBatchInsertBuilder instance
func (q *Q) NewOperationParticipantBatchInsertBuilder() OperationParticipantBatchInsertBuilder {
return &operationParticipantBatchInsertBuilder{
table: "history_operation_participants",
builder: db.FastBatchInsertBuilder{},
}
}
// Add adds an operation participant to the batch
func (i *operationParticipantBatchInsertBuilder) Add(
operationID int64,
accountID FutureAccountID,
) error {
return i.builder.Row(map[string]interface{}{
"history_operation_id": operationID,
"history_account_id": accountID,
})
}
func (i *operationParticipantBatchInsertBuilder) Exec(ctx context.Context, session db.SessionInterface) error {
return i.builder.Exec(ctx, session, i.table)
}