bgpwtf/cccampix: draw the rest of the fucking owl
Change-Id: I49fd5906e69512e8f2d414f406edc0179522f225
diff --git a/bgpwtf/cccampix/verifier/model/pgp.go b/bgpwtf/cccampix/verifier/model/pgp.go
new file mode 100644
index 0000000..a76186e
--- /dev/null
+++ b/bgpwtf/cccampix/verifier/model/pgp.go
@@ -0,0 +1,31 @@
+package model
+
+import (
+ "context"
+ "fmt"
+ "time"
+)
+
+func (s *sqlModel) UpdatePGPKey(ctx context.Context, key *PeerPGPKey) error {
+ q := `
+ INSERT INTO peer_pgp_keys
+ (peer_id, fingerprint, time_created)
+ SELECT
+ peers.id, :fingerprint, :time_created
+ FROM peers
+ WHERE peers.asn = :asn
+ ON CONFLICT (peer_id)
+ DO UPDATE SET
+ fingerprint = :fingerprint,
+ time_created = :time_created
+ `
+ data := &sqlPeerPGPKey{
+ Fingerprint: key.Fingerprint,
+ ASN: fmt.Sprintf("%d", key.PeerASN),
+ TimeCreated: time.Now().UnixNano(),
+ }
+ if _, err := s.db.NamedExecContext(ctx, q, data); err != nil {
+ return fmt.Errorf("INSERT peer_pgp_keys: %v", err)
+ }
+ return nil
+}