http_private: stored procedure: use VARBINARY(20) for peer_id

This commit is contained in:
Joakim Frostegård 2022-04-04 10:15:27 +02:00
parent 9fd1306b2e
commit 1cdd5bde5b
2 changed files with 6 additions and 6 deletions

View file

@ -38,8 +38,8 @@ CREATE OR REPLACE PROCEDURE aquatic_announce_v1 (
IN p_user_token VARCHAR(255),
-- Hex-encoded info hash
IN p_info_hash CHAR(40),
-- Peer ID
IN p_peer_id CHAR(40),
-- Peer ID. VARBINARY since it can be any bytes according to spec.
IN p_peer_id VARBINARY(20),
-- Event (started/stopped/completed) (can be NULL)
IN p_event VARCHAR(9),
-- Bytes uploaded. Passed directly from request.

View file

@ -2,7 +2,7 @@ use std::net::IpAddr;
use aquatic_common::CanonicalSocketAddr;
use aquatic_http_protocol::{
common::AnnounceEvent, request::AnnounceRequest, response::FailureResponse,
common::{AnnounceEvent, PeerId}, request::AnnounceRequest, response::FailureResponse,
};
use sqlx::{Executor, MySql, Pool};
@ -22,7 +22,7 @@ struct AnnounceProcedureParameters {
user_agent: Option<String>,
user_token: String,
info_hash: String,
peer_id: String,
peer_id: PeerId,
event: AnnounceEvent,
uploaded: u64,
downloaded: u64,
@ -42,7 +42,7 @@ impl AnnounceProcedureParameters {
user_agent,
user_token,
info_hash: hex::encode(request.info_hash.0),
peer_id: hex::encode(request.peer_id.0),
peer_id: request.peer_id,
event: request.event,
uploaded: request.bytes_uploaded as u64,
downloaded: request.bytes_downloaded as u64,
@ -127,7 +127,7 @@ async fn call_announce_procedure(
.bind(parameters.user_agent)
.bind(parameters.user_token)
.bind(parameters.info_hash)
.bind(parameters.peer_id)
.bind(&parameters.peer_id.0[..])
.bind(parameters.event.as_str())
.bind(parameters.uploaded)
.bind(parameters.downloaded)