-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adding a Token::is_zero API. - Re-adding workflow file for automatic releases.
- Loading branch information
Showing
8 changed files
with
149 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# auto merge workflow. | ||
# | ||
# Auto merge PR if commit msg begins with `chore(release):`, | ||
# or if it has been raised by Dependabot. | ||
# Uses https://github.com/ridedott/merge-me-action. | ||
|
||
name: Merge Version Change and Dependabot PRs automatically | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
merge: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: get commit message | ||
run: | | ||
commitmsg=$(git log --format=%s -n 1 ${{ github.event.pull_request.head.sha }}) | ||
echo "commitmsg=${commitmsg}" >> $GITHUB_ENV | ||
- name: show commit message | ||
run : echo $commitmsg | ||
|
||
- name: Merge Version change PR | ||
if: startsWith( env.commitmsg, 'chore(release):') | ||
uses: ridedott/merge-me-action@81667e6ae186ddbe6d3c3186d27d91afa7475e2c | ||
with: | ||
GITHUB_LOGIN: dirvine | ||
GITHUB_TOKEN: ${{ secrets.MERGE_BUMP_BRANCH_TOKEN }} | ||
MERGE_METHOD: REBASE | ||
|
||
- name: Dependabot Merge | ||
uses: ridedott/merge-me-action@v2 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
MERGE_METHOD: REBASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2023, MaidSafe. | ||
// All rights reserved. | ||
// | ||
// This SAFE Network Software is licensed under the BSD-3-Clause license. | ||
// Please see the LICENSE file for more details. | ||
|
||
use crate::{Hash, Token}; | ||
|
||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
#[derive(Debug, Clone, Eq, PartialEq)] | ||
pub struct FeeOutput { | ||
/// The id is expected (in order to be accepted by the network) to be built from: hash(root_hash + inputs' ids). | ||
/// This requirement makes it possible for this output to be used as an input in a rewards/farming | ||
/// claiming Tx, by making its spend location deterministic, analogous to how any other output | ||
/// is spent using its id to determine the location to store the signed spend. | ||
pub id: Hash, | ||
/// Amount being paid as storage fee to the network. | ||
pub token: Token, | ||
/// The root hash of the proof's Merkletree corresponding to the content being paid for. | ||
pub root_hash: Hash, | ||
} | ||
|
||
impl Default for FeeOutput { | ||
fn default() -> Self { | ||
Self { | ||
id: Hash::default(), | ||
token: Token::zero(), | ||
root_hash: Hash::default(), | ||
} | ||
} | ||
} | ||
|
||
impl FeeOutput { | ||
pub fn new(id: Hash, amount: u64, root_hash: Hash) -> Self { | ||
Self { | ||
id, | ||
token: Token::from_nano(amount), | ||
root_hash, | ||
} | ||
} | ||
|
||
pub fn is_free(&self) -> bool { | ||
self.token.is_zero() | ||
} | ||
|
||
pub fn to_bytes(&self) -> Vec<u8> { | ||
let mut v = Vec::<u8>::new(); | ||
v.extend(self.id.slice()); | ||
v.extend(self.token.to_bytes()); | ||
v.extend(self.root_hash.slice()); | ||
v | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters