Merge branch 'master' into master
This commit is contained in:
@@ -64,16 +64,28 @@ jobs:
|
||||
cargo install cross
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
cargo build --release
|
||||
cargo build --release --no-default-features --target-dir nogui
|
||||
run: cargo build --release
|
||||
- name: Build Windows release binaries with Edge
|
||||
if: contains(matrix.os, 'windows')
|
||||
run: |
|
||||
cargo build --release --features "edge" --target-dir edge
|
||||
- name: Build ARMv7 binary
|
||||
run: cross build --release --no-default-features --target armv7-unknown-linux-gnueabihf
|
||||
run: cargo build --release --features "edge" --target-dir edge
|
||||
- name: Build and package deb packages
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
PKGARCH=amd64 contrib/deb/generate.sh
|
||||
PKGARCH=i686 contrib/deb/generate.sh
|
||||
PKGARCH=mips contrib/deb/generate.sh
|
||||
PKGARCH=mipsel contrib/deb/generate.sh
|
||||
PKGARCH=armhf contrib/deb/generate.sh
|
||||
PKGARCH=arm64 contrib/deb/generate.sh
|
||||
|
||||
- name: Upload debs
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
tag_name="${{ needs.get_version.outputs.project_version }}"
|
||||
hub release edit $(find . -type f -name "*.deb" -printf "-a %p ") -m "" "$tag_name"
|
||||
|
||||
- name: win_arch
|
||||
run: |
|
||||
echo "BIN_ARCH=windows-amd64" >> $GITHUB_ENV
|
||||
@@ -96,8 +108,6 @@ jobs:
|
||||
echo "ZIP_NAME=alfis-${{env.BIN_ARCH}}-${{ needs.get_version.outputs.project_version }}.zip" >> $GITHUB_ENV
|
||||
echo "BIN_PATH_NOGUI=./nogui/release/alfis" >> $GITHUB_ENV
|
||||
echo "ZIP_NAME_NOGUI=alfis-${{env.BIN_ARCH}}-${{ needs.get_version.outputs.project_version }}-nogui.zip" >> $GITHUB_ENV
|
||||
echo "BIN_ARM_PATH=./target/armv7-unknown-linux-gnueabihf/release/alfis" >> $GITHUB_ENV
|
||||
echo "ZIP_ARM_NAME=alfis-armv7-${{ needs.get_version.outputs.project_version }}-nogui.zip" >> $GITHUB_ENV
|
||||
- name: Windows variables
|
||||
if: contains(matrix.os, 'windows')
|
||||
run: |
|
||||
@@ -107,6 +117,7 @@ jobs:
|
||||
echo "ZIP_NAME_NOGUI=alfis-${{env.BIN_ARCH}}-${{ needs.get_version.outputs.project_version }}-nogui.zip" >> $GITHUB_ENV
|
||||
echo "BIN_PATH_EDGE=edge/release/alfis.exe" >> $GITHUB_ENV
|
||||
echo "ZIP_NAME_EDGE=alfis-${{env.BIN_ARCH}}-${{ needs.get_version.outputs.project_version }}-edge.zip" >> $GITHUB_ENV
|
||||
|
||||
- name: Packaging
|
||||
uses: papeloto/action-zip@v1
|
||||
with:
|
||||
@@ -123,12 +134,7 @@ jobs:
|
||||
with:
|
||||
files: ${{ env.BIN_PATH_EDGE }} alfis.toml README.md LICENSE adblock.txt
|
||||
dest: ${{ env.ZIP_NAME_EDGE }}
|
||||
- name: Packaging ARM
|
||||
uses: papeloto/action-zip@v1
|
||||
with:
|
||||
files: ${{ env.BIN_ARM_PATH }} alfis.toml README.md LICENSE adblock.txt
|
||||
dest: ${{ env.ZIP_ARM_NAME }}
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
|
||||
- name: Upload binary
|
||||
id: upload-binary
|
||||
uses: actions/upload-release-asset@v1
|
||||
@@ -139,6 +145,7 @@ jobs:
|
||||
asset_path: ${{ env.ZIP_NAME }}
|
||||
asset_name: ${{ env.ZIP_NAME }}
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Upload no GUI binary
|
||||
id: upload-nogui-binary
|
||||
uses: actions/upload-release-asset@v1
|
||||
@@ -149,6 +156,7 @@ jobs:
|
||||
asset_path: ${{ env.ZIP_NAME_NOGUI }}
|
||||
asset_name: ${{ env.ZIP_NAME_NOGUI }}
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Upload Edge binary
|
||||
if: contains(matrix.os, 'windows')
|
||||
id: upload-edge-binary
|
||||
@@ -160,14 +168,3 @@ jobs:
|
||||
asset_path: ${{ env.ZIP_NAME_EDGE }}
|
||||
asset_name: ${{ env.ZIP_NAME_EDGE }}
|
||||
asset_content_type: application/zip
|
||||
- name: Upload ARM binary
|
||||
id: upload-arm-binary
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.make_release.outputs.upload_url }}
|
||||
asset_path: ${{ env.ZIP_ARM_NAME }}
|
||||
asset_name: ${{ env.ZIP_ARM_NAME }}
|
||||
asset_content_type: application/zip
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "alfis"
|
||||
version = "0.3.12"
|
||||
version = "0.3.13"
|
||||
authors = ["Revertron <alfis@revertron.com>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
@@ -14,7 +14,7 @@ PKGBRANCH=$(basename `git name-rev --name-only HEAD`)
|
||||
PKGNAME=$(sh contrib/semver/name.sh)
|
||||
PKGVERSION=$(sh contrib/semver/version.sh --bare)
|
||||
PKGARCH=${PKGARCH-amd64}
|
||||
PKGFILE=$PKGNAME-linux-$PKGARCH-$PKGVERSION-nogui.deb
|
||||
PKGFILE=$PKGNAME-linux-$PKGARCH-v$PKGVERSION-nogui.deb
|
||||
PKGREPLACES=alfis
|
||||
|
||||
#if [ $PKGBRANCH = "master" ]; then
|
||||
|
||||
+17
-13
@@ -63,6 +63,7 @@ impl Network {
|
||||
// Starting peer connections to bootstrap nodes
|
||||
peers.connect_peers(peers_addrs, &poll.registry(), &mut unique_token, yggdrasil_only);
|
||||
|
||||
let mut peers_timer = Instant::now();
|
||||
loop {
|
||||
// Poll Mio for events, blocking until we get an event.
|
||||
poll.poll(&mut events, POLL_TIMEOUT).expect("Error polling sockets");
|
||||
@@ -131,19 +132,22 @@ impl Network {
|
||||
}
|
||||
events.clear();
|
||||
|
||||
// Send pings to idle peers
|
||||
let (height, hash) = {
|
||||
let mut context = context.lock().unwrap();
|
||||
let height = context.chain.height();
|
||||
let nodes = peers.get_peers_active_count();
|
||||
if nodes > 0 {
|
||||
context.bus.post(crate::event::Event::NetworkStatus { nodes, blocks: height });
|
||||
}
|
||||
(height, context.chain.last_hash())
|
||||
};
|
||||
mine_locker_block(Arc::clone(&context));
|
||||
peers.send_pings(poll.registry(), height, hash);
|
||||
peers.connect_new_peers(poll.registry(), &mut unique_token, yggdrasil_only);
|
||||
if peers_timer.elapsed().as_millis() > 100 {
|
||||
// Send pings to idle peers
|
||||
let (height, hash) = {
|
||||
let mut context = context.lock().unwrap();
|
||||
let height = context.chain.height();
|
||||
let nodes = peers.get_peers_active_count();
|
||||
if nodes > 0 {
|
||||
context.bus.post(crate::event::Event::NetworkStatus { nodes, blocks: height });
|
||||
}
|
||||
(height, context.chain.last_hash())
|
||||
};
|
||||
mine_locker_block(Arc::clone(&context));
|
||||
peers.send_pings(poll.registry(), height, hash);
|
||||
peers.connect_new_peers(poll.registry(), &mut unique_token, yggdrasil_only);
|
||||
peers_timer = Instant::now();
|
||||
}
|
||||
}
|
||||
info!("Network loop finished");
|
||||
});
|
||||
|
||||
+40
-6
@@ -18,7 +18,7 @@ pub struct Peers {
|
||||
ignored: HashSet<IpAddr>
|
||||
}
|
||||
|
||||
const PING_PERIOD: u64 = 30;
|
||||
const PING_PERIOD: u64 = 60;
|
||||
|
||||
impl Peers {
|
||||
pub fn new() -> Self {
|
||||
@@ -44,7 +44,26 @@ impl Peers {
|
||||
let stream = peer.get_stream();
|
||||
let _ = stream.shutdown(Shutdown::Both);
|
||||
let _ = registry.deregister(stream);
|
||||
debug!("Peer connection {} to {:?} has shut down", &token.0, &peer.get_addr());
|
||||
match peer.get_state() {
|
||||
State::Connecting => {
|
||||
debug!("Peer connection {} to {:?} has timed out", &token.0, &peer.get_addr());
|
||||
}
|
||||
State::Connected => {
|
||||
debug!("Peer connection {} to {:?} disconnected", &token.0, &peer.get_addr());
|
||||
}
|
||||
State::Idle { .. } | State::Message { .. } => {
|
||||
debug!("Peer connection {} to {:?} disconnected", &token.0, &peer.get_addr());
|
||||
}
|
||||
State::Error => {
|
||||
debug!("Peer connection {} to {:?} has shut down on error", &token.0, &peer.get_addr());
|
||||
}
|
||||
State::Banned => {
|
||||
debug!("Peer connection {} to {:?} has shut down, banned", &token.0, &peer.get_addr());
|
||||
}
|
||||
State::Offline { .. } => {
|
||||
debug!("Peer connection {} to {:?} is offline", &token.0, &peer.get_addr());
|
||||
}
|
||||
}
|
||||
|
||||
if !peer.disabled() && !peer.is_inbound() {
|
||||
peer.set_state(State::offline());
|
||||
@@ -91,7 +110,12 @@ impl Peers {
|
||||
continue;
|
||||
}
|
||||
|
||||
if skip_addr(&addr) {
|
||||
if self.ignored.contains(&addr.ip()) {
|
||||
trace!("Skipping address from exchange: {}", &addr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if skip_private_addr(&addr) {
|
||||
//debug!("Skipping address from exchange: {}", &addr);
|
||||
continue; // Return error in future
|
||||
}
|
||||
@@ -233,8 +257,18 @@ impl Peers {
|
||||
}
|
||||
}
|
||||
|
||||
let mut offline_ips = Vec::new();
|
||||
// Remove all peers that are offline for a long time
|
||||
self.peers.retain(|_, p| { !(p.get_state().need_reconnect() && p.reconnects() >= MAX_RECONNECTS) });
|
||||
self.peers.retain(|_, p| {
|
||||
let offline = p.get_state().need_reconnect() && p.reconnects() >= MAX_RECONNECTS;
|
||||
if offline {
|
||||
offline_ips.push(p.get_addr().ip());
|
||||
}
|
||||
!offline
|
||||
});
|
||||
for ip in offline_ips {
|
||||
self.ignore_ip(&ip);
|
||||
}
|
||||
|
||||
for (token, peer) in self.peers.iter_mut() {
|
||||
if peer.get_state().need_reconnect() {
|
||||
@@ -286,7 +320,7 @@ impl Peers {
|
||||
}
|
||||
if let Ok(mut stream) = TcpStream::connect(addr.clone()) {
|
||||
let token = next(unique_token);
|
||||
debug!("Trying to reconnect connection {}, to peer {}", &token.0, &addr);
|
||||
debug!("Created connection {}, to peer {}", &token.0, &addr);
|
||||
registry.register(&mut stream, token, Interest::WRITABLE).unwrap();
|
||||
let mut peer = Peer::new(addr.clone(), stream, State::Connecting, false);
|
||||
peer.set_public(true);
|
||||
@@ -295,7 +329,7 @@ impl Peers {
|
||||
}
|
||||
}
|
||||
|
||||
fn skip_addr(addr: &SocketAddr) -> bool {
|
||||
fn skip_private_addr(addr: &SocketAddr) -> bool {
|
||||
if addr.ip().is_loopback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user