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

feat: chunk payments using UTXOs instead of DBCs #721

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sn_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ libp2p = { version="0.52", features = ["identify", "kad"] }
reqwest = { version="0.11.18", default-features=false, features = ["rustls"] }
sn_build_info = { path="../sn_build_info", version = "0.1.2" }
sn_client = { path = "../sn_client", version = "0.89.0" }
sn_dbc = { version = "19.1.1", features = ["serdes"] }
sn_dbc = { version = "20.0.0", features = ["serdes"] }
sn_transfers = { path = "../sn_transfers", version = "0.11.9" }
sn_logging = { path = "../sn_logging", version = "0.2.6" }
sn_peers_acquisition= { path="../sn_peers_acquisition", version = "0.1.6" }
Expand Down
2 changes: 1 addition & 1 deletion sn_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rand = { version = "~0.8.5", features = ["small_rng"] }
rayon = "~1.5.1"
self_encryption = "~0.28.4"
serde = { version = "1.0.133", features = [ "derive", "rc" ]}
sn_dbc = { version = "19.1.1", features = ["serdes"] }
sn_dbc = { version = "20.0.0", features = ["serdes"] }
sn_networking = { path = "../sn_networking", version = "0.6.0" }
sn_protocol = { path = "../sn_protocol", version = "0.6.6" }
sn_registers = { path = "../sn_registers", version = "0.2.6" }
Expand Down
6 changes: 3 additions & 3 deletions sn_client/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::{
use bls::{PublicKey, SecretKey, Signature};
use indicatif::ProgressBar;
use libp2p::{kad::Record, Multiaddr};
use sn_dbc::{Dbc, DbcId, PublicAddress, SignedSpend, Token};
use sn_dbc::{DbcId, PublicAddress, SignedSpend, Token};
use sn_networking::{multiaddr_is_global, NetworkEvent, SwarmDriver, CLOSE_GROUP_SIZE};
use sn_protocol::{
error::Error as ProtocolError,
Expand All @@ -25,7 +25,7 @@ use sn_protocol::{
NetworkAddress, PrettyPrintRecordKey,
};
use sn_registers::SignedRegister;
use sn_transfers::client_transfers::SpendRequest;
use sn_transfers::{client_transfers::SpendRequest, wallet::Transfer};
use std::time::Duration;
use tokio::{sync::OwnedSemaphorePermit, task::spawn};
use tracing::trace;
Expand Down Expand Up @@ -291,7 +291,7 @@ impl Client {
pub(super) async fn store_chunk(
&self,
chunk: Chunk,
payment: Vec<Dbc>,
payment: Vec<Transfer>,
verify_store: bool,
optional_permit: Option<OwnedSemaphorePermit>,
) -> Result<()> {
Expand Down
6 changes: 2 additions & 4 deletions sn_client/src/file_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,10 @@ impl Files {
trace!("Client upload started for chunk: {chunk_addr:?}");

let wallet_client = self.wallet()?;
let payment = wallet_client.get_payment_dbcs(&chunk_addr);
let payment = wallet_client.get_payment_transfers(&chunk_addr)?;

if payment.is_empty() {
warn!(
"Failed to get payment proof for chunk: {chunk_addr:?} it was not found in the local wallet",
);
warn!("Failed to get payment proof for chunk: {chunk_addr:?} it was not found in the local wallet");
return Err(Error::NoPaymentForRecord(PrettyPrintRecordKey::from(
chunk_addr.to_record_key(),
)))?;
Expand Down
9 changes: 5 additions & 4 deletions sn_client/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use sn_transfers::client_transfers::SpendRequest;
use sn_transfers::{client_transfers::SpendRequest, wallet::Transfer};

use super::Client;

Expand Down Expand Up @@ -57,9 +57,10 @@ impl WalletClient {
self.wallet.unconfirmed_txs()
}

/// Get the payment dbc for a given network address
pub fn get_payment_dbcs(&self, address: &NetworkAddress) -> Vec<Dbc> {
self.wallet.get_payment_dbcs(address)
/// Get the payment transfers for a given network address
pub fn get_payment_transfers(&self, address: &NetworkAddress) -> Result<Vec<Transfer>> {
let dbcs = self.wallet.get_payment_dbcs(address);
self.wallet.create_transfers(dbcs)
}

/// Send tokens to another wallet.
Expand Down
2 changes: 1 addition & 1 deletion sn_networking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rand = { version = "~0.8.5", features = ["small_rng"] }
rmp-serde = "1.1.1"
serde = { version = "1.0.133", features = [ "derive", "rc" ]}
sn_protocol = { path = "../sn_protocol", version = "0.6.6" }
sn_dbc = { version = "19.1.1", features = ["serdes"] }
sn_dbc = { version = "20.0.0", features = ["serdes"] }
thiserror = "1.0.23"
tokio = { version = "1.32.0", features = ["io-util", "macros", "parking_lot", "rt", "sync", "time"] }
tracing = { version = "~0.1.26" }
Expand Down
2 changes: 1 addition & 1 deletion sn_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ self_encryption = "~0.28.4"
serde = { version = "1.0.133", features = [ "derive", "rc" ]}
sn_build_info = { path="../sn_build_info", version = "0.1.2" }
sn_peers_acquisition= { path="../sn_peers_acquisition", version = "0.1.6" }
sn_dbc = { version = "19.1.1", features = ["serdes"] }
sn_dbc = { version = "20.0.0", features = ["serdes"] }
sn_client = { path = "../sn_client", version = "0.89.0" }
sn_logging = { path = "../sn_logging", version = "0.2.6" }
sn_networking = { path = "../sn_networking", version = "0.6.0" }
Expand Down