Skip to content

Commit

Permalink
jobbid fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Aug 10, 2024
1 parent 26bbc38 commit 142a840
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions crates/common/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ impl Display for Job {

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct JobBid {
pub identity: PeerId,
pub job_hash: u64,
pub price: u64,
}
Expand Down
8 changes: 4 additions & 4 deletions crates/delegator/src/delegator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ impl Delegator {
},
Some(event) = swarm_events.next() => {
match event {
PeerBehaviourEvent::Gossipsub(gossipsub::Event::Message { message, propagation_source, .. }) => {
PeerBehaviourEvent::Gossipsub(gossipsub::Event::Message { message, .. }) => {
if message.topic == Topic::Market.into() {
match serde_json::from_slice::<MarketMessage>(&message.data)? {
MarketMessage::JobBid(job_bid) => {
if let Some(bid_tx) = job_hash_store.get_mut(&job_bid.job_hash) {
info!("Received job bid: {} price: {} from: {}", job_bid.job_hash, job_bid.price, propagation_source);
bid_tx.send((job_bid.price, propagation_source)).await?;
events_tx.send((job_bid.job_hash, DelegatorEvent::BidReceived(propagation_source)))?;
info!("Received job bid: {} price: {} from: {}", job_bid.job_hash, job_bid.price, job_bid.identity);
bid_tx.send((job_bid.price, job_bid.identity)).await?;
events_tx.send((job_bid.job_hash, DelegatorEvent::BidReceived(job_bid.identity)))?;
}
}
_ => {}
Expand Down
1 change: 1 addition & 0 deletions crates/executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl Executor {
.send(GossipsubMessage {
topic: Topic::Market.into(),
data: serde_json::to_vec(&MarketMessage::JobBid(JobBid {
identity,
job_hash: hash!(job),
price: (runner_scheduler.len() * prover_scheduler.len()) as u64,
}))?
Expand Down

0 comments on commit 142a840

Please sign in to comment.