Skip to content

Commit

Permalink
Expose public parameters and Position fns in no-std
Browse files Browse the repository at this point in the history
  • Loading branch information
aterentic-ethernal committed Oct 7, 2024
1 parent 99e37cf commit b845db8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
12 changes: 8 additions & 4 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion kate/recovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ authors = ["Denis Ermolin <[email protected]>"]
edition = "2018"
license = "Apache-2.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.15", features = ["js"] }
sp-io = { workspace = true, features = [ "disable_panic_handler" ] }

[dependencies]
# Internals
avail-core = { path = "../../core", default-features = false }
dusk-plonk = { workspace = true, optional = true }
dusk-plonk = { workspace = true }

# Parity
codec = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
Expand Down
6 changes: 5 additions & 1 deletion kate/recovery/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ use sp_std::{collections::btree_map::BTreeMap, vec::Vec};

use crate::matrix::{Dimensions, Position, RowIndex};

#[cfg(target_arch = "wasm32")]
extern crate alloc;
#[cfg(target_arch = "wasm32")]
use alloc::string::String;

/// Position and data of a cell in extended matrix
#[derive(Default, Debug, Clone, Constructor)]
pub struct DataCell {
Expand All @@ -23,7 +28,6 @@ pub struct Cell {
}

impl Cell {
#[cfg(feature = "std")]
pub fn reference(&self, block: u32) -> String {
self.position.reference(block)
}
Expand Down
1 change: 0 additions & 1 deletion kate/recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ pub mod sparse_slice_read;
#[cfg(feature = "std")]
pub mod testnet;

#[cfg(feature = "std")]
pub mod couscous;
7 changes: 5 additions & 2 deletions kate/recovery/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ use sp_std::vec;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[cfg(target_arch = "wasm32")]
extern crate alloc;
#[cfg(target_arch = "wasm32")]
use alloc::{format, string::String};

/// Position of a cell in the the matrix.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Default, Debug, Clone, Copy, Hash, Eq, PartialEq, Constructor)]
Expand Down Expand Up @@ -51,7 +56,6 @@ impl Display for Position {

impl Position {
/// Reference in format `block_number:column_number:row_number`
#[cfg(feature = "std")]
pub fn reference(&self, block_number: u32) -> String {
format!("{}:{}", block_number, self)
}
Expand All @@ -76,7 +80,6 @@ pub struct RowIndex(pub u32);

impl RowIndex {
/// Reference in format `block_number:row_number`
#[cfg(feature = "std")]
pub fn reference(&self, block_number: u32) -> String {
format!("{}:{}", block_number, self.0)
}
Expand Down

0 comments on commit b845db8

Please sign in to comment.