Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.32 #868

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.31
0.2.32
4 changes: 2 additions & 2 deletions saito-core/src/core/consensus/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ impl Mempool {
return None;
}
if !self.blocks_queue.is_empty() {
debug!("there are blocks in queue");
trace!("there are blocks in queue");
return None;
}
if self.transactions.is_empty() || !self.new_tx_added {
debug!("there are no transactions in queue");
trace!("there are no transactions in queue");
return None;
}
if !blockchain.is_golden_ticket_count_valid(
Expand Down
4 changes: 2 additions & 2 deletions saito-core/src/core/consensus_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl ConsensusThread {
}

pub async fn produce_block(&mut self, timestamp: Timestamp, produce_without_limits: bool) {
debug!("producing a block");
trace!("producing a block");
let configs = self.network.config_lock.read().await;

let mut blockchain = self.blockchain_lock.write().await;
Expand Down Expand Up @@ -168,7 +168,7 @@ impl ConsensusThread {
)
.await;
} else {
info!("skipped bundling block");
trace!("skipped bundling block");
}
if let Some(block) = block {
debug!(
Expand Down
2 changes: 1 addition & 1 deletion saito-core/src/core/routing_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ impl ProcessEvent<RoutingEvent> for RoutingThread {

let mut work_done = false;

const RECONNECTION_PERIOD: Timestamp = 10_000;
const RECONNECTION_PERIOD: Timestamp = Duration::from_secs(2).as_millis() as Timestamp;
self.reconnection_timer += duration_value;
let current_time = self.timer.get_timestamp_in_ms();
if self.reconnection_timer >= RECONNECTION_PERIOD {
Expand Down
55 changes: 29 additions & 26 deletions saito-js/lib/custom/shared_methods.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,39 +110,42 @@ export default class WebSharedMethods extends CustomSharedMethods {
}

sendMessage(peerIndex: bigint, buffer: Uint8Array): void {
if (Saito.getInstance().stunManager.isStunPeer(peerIndex)) {
const stunPeer = Saito.getInstance().stunManager.getStunPeer(peerIndex);
if (stunPeer) {
//@ts-ignore
const { peerConnection, publicKey } = stunPeer;
//@ts-ignore
const dc = peerConnection.dc;
if (dc) {
if (dc.readyState === 'open') {
console.log(`Sending message to STUN peer ${peerIndex} via data channel`);
try {
dc.send(buffer);
} catch (error) {
console.error(`Error sending message to STUN peer ${peerIndex} via data channel:`, error);
try {
if (Saito.getInstance().stunManager.isStunPeer(peerIndex)) {
const stunPeer = Saito.getInstance().stunManager.getStunPeer(peerIndex);
if (stunPeer) {
//@ts-ignore
const {peerConnection, publicKey} = stunPeer;
//@ts-ignore
const dc = peerConnection.dc;
if (dc) {
if (dc.readyState === 'open') {
console.log(`Sending message to STUN peer ${peerIndex} via data channel`);
try {
dc.send(buffer);
} catch (error) {
console.error(`Error sending message to STUN peer ${peerIndex} via data channel:`, error);
}
} else {
console.warn(`Data channel for STUN peer ${peerIndex} is not open. Current state: ${dc.readyState}`);
}
} else {
console.warn(`Data channel for STUN peer ${peerIndex} is not open. Current state: ${dc.readyState}`);
console.warn(`Data channel for STUN peer ${peerIndex} is not initialized`);
}
} else {
console.warn(`Data channel for STUN peer ${peerIndex} is not initialized`);
console.warn(`STUN peer ${peerIndex} not found`);
}
} else {
console.warn(`STUN peer ${peerIndex} not found`);
return;
}
return;
}


let socket = Saito.getInstance().getSocket(peerIndex);
if (socket) {
socket.send(buffer);
} else {
console.error(`No WebSocket found for peer ${peerIndex}`);
let socket = Saito.getInstance().getSocket(peerIndex);
if (socket) {
socket.send(buffer);
} else {
console.error(`No WebSocket found for peer ${peerIndex}`);
}
} catch (e) {
console.error(e);
}
}

Expand Down
Loading