Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from pokt-foundation/feat-Write-Relays-include…
Browse files Browse the repository at this point in the history
…s-plugin

feat: add blocking_plugin to WriteRelays
  • Loading branch information
adshmh authored Oct 25, 2023
2 parents d40039c + 4504a09 commit df5b0a0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions postgres-driver/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const insertRelays = `INSERT INTO relay (
pokt_tx_id,
gigastake_app_id,
created_at,
updated_at
updated_at,
blocking_plugin
)
SELECT * FROM unnest(
$1::char(4)[],
Expand Down Expand Up @@ -72,7 +73,8 @@ const insertRelays = `INSERT INTO relay (
$27::varchar[],
$28::varchar[],
$29::timestamp[],
$30::timestamp[]
$30::timestamp[],
$31::varchar[]
) AS t(
pokt_chain_id,
endpoint_id,
Expand Down Expand Up @@ -103,7 +105,8 @@ const insertRelays = `INSERT INTO relay (
pokt_tx_id,
gigastake_app_id,
created_at,
updated_at
updated_at,
blocking_plugin
)`

const chainMethodIDSeparator = ","
Expand Down Expand Up @@ -142,6 +145,7 @@ func (d *PostgresDriver) WriteRelay(ctx context.Context, relay types.Relay) erro
GigastakeAppID: newSQLNullString(relay.GigastakeAppID),
CreatedAt: now,
UpdatedAt: now,
BlockingPlugin: newSQLNullString(relay.BlockingPlugin),
})
}

Expand Down Expand Up @@ -179,6 +183,7 @@ func (d *PostgresDriver) WriteRelays(ctx context.Context, relays []*types.Relay)
gigastakeAppIDs []sql.NullString
createdTimes []time.Time
updatedTimes []time.Time
blockingPlugins []sql.NullString
)

for _, relay := range relays {
Expand Down Expand Up @@ -212,6 +217,7 @@ func (d *PostgresDriver) WriteRelays(ctx context.Context, relays []*types.Relay)
gigastakeAppIDs = append(gigastakeAppIDs, newSQLNullString(relay.GigastakeAppID))
createdTimes = append(createdTimes, now)
updatedTimes = append(updatedTimes, now)
blockingPlugins = append(blockingPlugins, newSQLNullString(relay.BlockingPlugin))
}

_, err := d.db.Exec(insertRelays, pq.StringArray(poktChainIDs),
Expand Down Expand Up @@ -243,7 +249,8 @@ func (d *PostgresDriver) WriteRelays(ctx context.Context, relays []*types.Relay)
pq.Array(poktTxIDs),
pq.Array(gigastakeAppIDs),
pq.Array(createdTimes),
pq.Array(updatedTimes))
pq.Array(updatedTimes),
pq.Array(blockingPlugins))
if err != nil {
return err
}
Expand Down

0 comments on commit df5b0a0

Please sign in to comment.