mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
Take iterator in calculate_hash()
Avoids unnecessary allocations.
This commit is contained in:
parent
cce83beedb
commit
f1642c92d1
5 changed files with 24 additions and 33 deletions
|
|
@ -755,17 +755,10 @@ async fn handle_appservice_event(
|
|||
appservice::event::push_events::v1::Request {
|
||||
events: pdu_jsons,
|
||||
txn_id: general_purpose::URL_SAFE_NO_PAD
|
||||
.encode(calculate_hash(
|
||||
&events
|
||||
.iter()
|
||||
.map(|e| match e {
|
||||
SendingEventType::Edu(b) => {
|
||||
b.json().get().as_bytes()
|
||||
}
|
||||
SendingEventType::Pdu(b) => b.as_bytes(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
))
|
||||
.encode(calculate_hash(events.iter().map(|e| match e {
|
||||
SendingEventType::Edu(b) => b.json().get().as_bytes(),
|
||||
SendingEventType::Pdu(b) => b.as_bytes(),
|
||||
})))
|
||||
.into(),
|
||||
},
|
||||
)
|
||||
|
|
@ -902,17 +895,10 @@ async fn handle_federation_event(
|
|||
edus: edu_jsons,
|
||||
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
|
||||
transaction_id: general_purpose::URL_SAFE_NO_PAD
|
||||
.encode(calculate_hash(
|
||||
&events
|
||||
.iter()
|
||||
.map(|e| match e {
|
||||
SendingEventType::Edu(b) => {
|
||||
b.json().get().as_bytes()
|
||||
}
|
||||
SendingEventType::Pdu(b) => b.as_bytes(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
))
|
||||
.encode(calculate_hash(events.iter().map(|e| match e {
|
||||
SendingEventType::Edu(b) => b.json().get().as_bytes(),
|
||||
SendingEventType::Pdu(b) => b.as_bytes(),
|
||||
})))
|
||||
.into(),
|
||||
},
|
||||
false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue