Commit 48d1a14f authored by Éloïs's avatar Éloïs

[feat] add crate dubp-indexes and define indexes in to it

parent 9f18fb00
......@@ -360,13 +360,13 @@ version = "0.1.0"
dependencies = [
"dubp-common-doc 0.1.0",
"dubp-currency-params 0.2.0",
"dubp-user-docs 0.14.0",
"dup-crypto 0.7.0",
"durs-common-tools 0.2.0",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
"shrinkwraprs 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"unwrap 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -481,6 +481,7 @@ dependencies = [
"dubp-block-doc 0.1.0",
"dubp-common-doc 0.1.0",
"dubp-currency-params 0.2.0",
"dubp-indexes 0.1.0",
"dubp-user-docs 0.14.0",
"dubp-user-docs-tests-tools 0.1.0",
"dup-crypto 0.7.0",
......
......@@ -10,6 +10,7 @@ members = [
"lib/dubp/block-doc",
"lib/dubp/common-doc",
"lib/dubp/currency-params",
"lib/dubp/indexes",
"lib/dubp/user-docs",
"lib/dubp/wot",
"lib/dunp/network-documents",
......
......@@ -630,7 +630,7 @@ mod tests {
CertificationDocument, CertificationDocumentParser,
};
use dubp_user_docs::documents::membership::{MembershipDocument, MembershipDocumentParser};
use dubp_user_docs::documents::transaction::{TransactionDocument, TransactionDocumentParser};
use dubp_user_docs::documents::transaction::TransactionDocumentParser;
#[test]
fn generate_and_verify_empty_block() {
......
[package]
name = "dubp-indexes"
version = "0.1.0"
authors = ["elois <elois@ifee.fr>"]
description = "Provides the definition of the indexes described in the DUBP RFC (DUBP: DUniter Blockhain Protocol)."
repository = "https://git.duniter.org/nodes/rust/duniter-rs"
readme = "README.md"
keywords = ["dunitrust", "duniter", "blockchain", "cryptocurrency", "block", "dubp"]
license = "AGPL-3.0"
edition = "2018"
[lib]
path = "src/lib.rs"
[dependencies]
dubp-common-doc = { path = "../common-doc"} #, version = "0.1.0" }
dubp-user-docs = { path = "../user-docs"} #, version = "0.1.0" }
dubp-currency-params = { path = "../currency-params", version = "0.2.0" }
dup-crypto = { path = "../../crypto", version = "0.7.0" }
durs-common-tools = { path = "../../tools/common-tools", version = "0.2.0" }
failure = "0.1.5"
log = "0.4.*"
serde = { version = "1.0.*", features = ["derive"] }
shrinkwraprs = "0.2.*"
unwrap = "1.2.1"
[dev-dependencies]
pretty_assertions = "0.5.1"
[features]
\ No newline at end of file
# DUBP indexes
This crate provides the definition of the indexes described in the [DUBP RFC](dubp-latest-rfc).
[dubp-latest-rfc]: https://git.duniter.org/nodes/common/doc/blob/master/rfc/0009_Duniter_Blockchain_Protocol_V11.md
## How to use it
You can add `dubp-indexes` as a `cargo` dependency in your Rust project.
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the certification index (CINDEX) described in the DUBP RFC.
pub mod v11;
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the certification index (CINDEX) described in the DUBP RFC v11.
use crate::{Index, IndexLineOp, MergeIndexLine};
use dubp_common_doc::blockstamp::Blockstamp;
use dup_crypto::keys::{PubKey, Sig};
/// CINDEX datas
pub type CIndexV11 = Index<(PubKey, PubKey), CIndexV11Line>;
#[derive(Clone, Copy, Debug)]
/// CINDEX line
pub struct CIndexV11Line {
op: IndexLineOp,
issuer: PubKey,
receiver: PubKey,
created_on: Option<Blockstamp>,
written_on: Option<Blockstamp>,
sig: Option<Sig>,
expires_on: Option<u64>,
expired_on: u64,
chainable_on: Option<u64>,
replayable_on: Option<u64>,
}
impl MergeIndexLine for CIndexV11Line {
fn merge_index_line(&mut self, index_line: Self) {
self.op = index_line.op;
self.issuer = index_line.issuer;
self.receiver = index_line.receiver;
index_line.created_on.map(|v| self.created_on.replace(v));
index_line.written_on.map(|v| self.written_on.replace(v));
index_line.sig.map(|v| self.sig.replace(v));
index_line.expires_on.map(|v| self.expires_on.replace(v));
self.expired_on = index_line.expired_on;
index_line
.chainable_on
.map(|v| self.chainable_on.replace(v));
index_line
.replayable_on
.map(|v| self.replayable_on.replace(v));
}
}
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the identity index (IINDEX) described in the DUBP RFC.
pub mod v11;
use durs_common_tools::fns::arrays::copy_into_array;
use std::convert::AsMut;
use std::fmt::{Debug, Error, Formatter};
use std::iter::Iterator;
use std::str::FromStr;
const USERNAME_MAX_LEN: usize = 100;
#[derive(Copy, Clone)]
/// Identity username
pub struct Username {
chars: UsernameChars,
real_len: usize,
}
impl Debug for Username {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
write!(f, "{:?}", &self.chars.0[..self.real_len])
}
}
#[derive(Copy, Clone)]
struct UsernameChars([char; USERNAME_MAX_LEN]);
impl AsMut<[char]> for UsernameChars {
fn as_mut(&mut self) -> &mut [char] {
&mut self.0[..]
}
}
impl Default for UsernameChars {
fn default() -> Self {
UsernameChars([
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
])
}
}
impl ToString for Username {
fn to_string(&self) -> String {
self.chars.0[..self.real_len].iter().collect()
}
}
/// Error when parsing username
#[derive(Clone, Copy, Debug)]
pub enum ParseUsernameErr {
/// username too long
UsernameTooLong,
}
impl FromStr for Username {
type Err = ParseUsernameErr;
fn from_str(source: &str) -> Result<Self, Self::Err> {
if source.len() > USERNAME_MAX_LEN {
return Err(ParseUsernameErr::UsernameTooLong);
}
let mut chars: Vec<char> = source.chars().collect();
let real_len = chars.len();
if real_len < USERNAME_MAX_LEN {
let mut whitespaces: Vec<char> =
(0..USERNAME_MAX_LEN - real_len).map(|_| ' ').collect();
chars.append(&mut whitespaces);
}
Ok(Username {
chars: copy_into_array(&chars[..]),
real_len,
})
}
}
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the identity index (IINDEX) described in the DUBP RFC v11.
use crate::iindex::Username;
use crate::{Index, IndexLineOp, MergeIndexLine};
use dubp_common_doc::blockstamp::Blockstamp;
use dup_crypto::hashs::Hash;
use dup_crypto::keys::{PubKey, Sig};
/// IINDEX datas
pub type IIndexV11 = Index<PubKey, IIndexV11Line>;
#[derive(Clone, Copy, Debug)]
/// IINDEX line
///
/// computed fields :
/// - wasMember: NULL if kick=1 or member=0, 1 otherwise
pub struct IIndexV11Line {
op: IndexLineOp,
uid: Option<Username>,
r#pub: PubKey,
hash: Option<Hash>, // sha256(uid ++ pub ++ created_on)
sig: Option<Sig>,
created_on: Option<Blockstamp>,
written_on: Blockstamp,
member: Option<bool>,
kick: Option<bool>,
}
impl MergeIndexLine for IIndexV11Line {
fn merge_index_line(&mut self, index_line: Self) {
self.op = index_line.op;
index_line.uid.map(|v| self.uid.replace(v));
index_line.hash.map(|v| self.hash.replace(v));
index_line.sig.map(|v| self.sig.replace(v));
index_line.created_on.map(|v| self.created_on.replace(v));
self.written_on = index_line.written_on;
index_line.sig.map(|v| self.sig.replace(v));
index_line.member.map(|v| self.member.replace(v));
index_line.kick.map(|v| self.kick.replace(v));
}
}
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the indexes described in the DUBP RFC.
#![deny(
missing_docs,
missing_debug_implementations,
missing_copy_implementations,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features,
unused_import_braces
)]
pub mod cindex;
pub mod iindex;
pub mod mindex;
pub mod sindex;
use shrinkwraprs::Shrinkwrap;
use std::collections::HashMap;
use std::fmt::Debug;
use std::hash::Hash;
/// Index line op column (CREATE or UPDATE)
///
/// Stored in a boolean :
/// CREATE encoded as true
/// UPDATE encoded as false
#[derive(Clone, Copy, Debug, Shrinkwrap)]
pub struct IndexLineOp(bool);
/// Generic INDEX
#[derive(Clone, Debug)]
pub struct Index<ID, IndexLine>
where
ID: Clone + Debug + Eq + Hash,
IndexLine: Debug + MergeIndexLine,
{
datas: HashMap<ID, Vec<IndexLine>>,
}
impl<ID, IndexLine> Index<ID, IndexLine>
where
ID: Clone + Debug + Eq + Hash,
IndexLine: Copy + Debug + MergeIndexLine,
{
/// Get entity state
pub fn get_state(&self, entity_id: &ID) -> Option<IndexLine> {
self.get_events(entity_id).map(Self::reduce)
}
}
impl<ID, IndexLine> Index<ID, IndexLine>
where
ID: Clone + Debug + Eq + Hash,
IndexLine: Clone + Debug + MergeIndexLine,
{
/// Get entity events
pub fn get_events(&self, entity_id: &ID) -> Option<&[IndexLine]> {
self.datas
.get(entity_id)
.map(|index_lines| &index_lines[..])
}
}
impl<ID, IndexLine> ReduceIndexLines for Index<ID, IndexLine>
where
ID: Clone + Debug + Eq + Hash,
IndexLine: Copy + Debug + MergeIndexLine,
{
type IndexLine = IndexLine;
}
impl<ID, IndexLine> ReduceNotCopyableIndexLines for Index<ID, IndexLine>
where
ID: Clone + Debug + Eq + Hash,
IndexLine: Clone + Debug + MergeIndexLine,
{
type IndexLine = IndexLine;
}
/// Merge one index line with another
pub trait MergeIndexLine {
/// Merge one index line with another
///
/// `self` is the current state of the entity.
/// `index_line` is the event to "apply" to the entity
fn merge_index_line(&mut self, index_line: Self);
}
/// Reduce all index lines into one to obtain the current state of the entity.
pub trait ReduceIndexLines {
/// Index line (represent one event on an entity)
type IndexLine: Copy + MergeIndexLine;
/// Each index line represents an event on an entity.
/// This function reduce all index lines into one to obtain the current state of the entity.
fn reduce(index_lines: &[Self::IndexLine]) -> Self::IndexLine {
let mut entity_state = index_lines[0];
for index_line in &index_lines[1..] {
entity_state.merge_index_line(*index_line);
}
entity_state
}
}
/// Reduce all index lines into one to obtain the current state of the entity.
pub trait ReduceNotCopyableIndexLines {
/// Index line (represent one event on an entity)
type IndexLine: Clone + MergeIndexLine;
/// Each index line represents an event on an entity.
/// This function reduce all index lines into one to obtain the current state of the entity.
fn reduce_by_cloning(index_lines: &[Self::IndexLine]) -> Self::IndexLine {
let mut entity_state = index_lines[0].clone();
for index_line in &index_lines[1..] {
entity_state.merge_index_line(index_line.clone());
}
entity_state
}
}
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the membership index (MINDEX) described in the DUBP RFC.
pub mod v11;
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the membership index (MINDEX) described in the DUBP RFC v11.
use crate::{Index, IndexLineOp, MergeIndexLine};
use dubp_common_doc::blockstamp::Blockstamp;
use dup_crypto::keys::{PubKey, Sig};
/// MINDEX datas
pub type MIndexV11 = Index<PubKey, MIndexV11Line>;
#[derive(Clone, Copy, Debug)]
/// MINDEX line
///
/// computed fields :
/// -
pub struct MIndexV11Line {
op: IndexLineOp,
r#pub: PubKey,
created_on: Option<Blockstamp>,
written_on: Blockstamp,
expires_on: Option<u64>,
expired_on: Option<u64>,
revokes_on: Option<u64>,
revoked_on: Option<Blockstamp>,
leaving: Option<bool>,
revocation: Option<Sig>,
chainable_on: Option<u64>,
}
impl MergeIndexLine for MIndexV11Line {
fn merge_index_line(&mut self, index_line: Self) {
self.op = index_line.op;
index_line.created_on.map(|v| self.created_on.replace(v));
self.written_on = index_line.written_on;
index_line.expires_on.map(|v| self.expires_on.replace(v));
index_line.expired_on.map(|v| self.expired_on.replace(v));
index_line.revokes_on.map(|v| self.revokes_on.replace(v));
index_line.revoked_on.map(|v| self.revoked_on.replace(v));
index_line.leaving.map(|v| self.leaving.replace(v));
index_line.revocation.map(|v| self.revocation.replace(v));
index_line
.chainable_on
.map(|v| self.chainable_on.replace(v));
}
}
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the source index (SINDEX) described in the DUBP RFC.
pub mod v11;
use dubp_common_doc::BlockNumber;
use dubp_user_docs::documents::transaction::OutputIndex;
use dup_crypto::hashs::Hash;
use dup_crypto::keys::PubKey;
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
/// Unique identifier for Unused tx output v10
pub struct UniqueIdUTXOv10(pub Hash, pub OutputIndex);
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
/// Index of a V10 source
pub enum SourceUniqueIdV10 {
/// unused Transaction Output
UTXO(UniqueIdUTXOv10),
/// universal Dividend
UD(PubKey, BlockNumber),
}
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Provides the definition of the source index (SINDEX) described in the DUBP RFC v11.
use super::SourceUniqueIdV10;
use crate::{Index, IndexLineOp, MergeIndexLine};
use dubp_common_doc::blockstamp::Blockstamp;
use dubp_user_docs::documents::transaction::{TxAmount, TxBase, UTXOConditions};
use dup_crypto::hashs::Hash;
/// SINDEX datas
pub type SIndexV11 = Index<SourceUniqueIdV10, SIndexV11Line>;
#[derive(Clone, Debug)]
/// SINDEX line
///
/// computed fields :
/// - consumed: true if op == UPDATE, false otherwise.
pub struct SIndexV11Line {
op: IndexLineOp,
tx: Option<Hash>,
identifier_and_pos: SourceUniqueIdV10,
created_on: Option<Blockstamp>,
amount: TxAmount,
base: TxBase,
locktime: usize,
conditions: UTXOConditions,
written_on: Blockstamp,
}
impl MergeIndexLine for SIndexV11Line {
fn merge_index_line(&mut self, index_line: Self) {
self.op = index_line.op;
index_line.tx.map(|v| self.tx.replace(v));
self.identifier_and_pos = index_line.identifier_and_pos;
index_line.created_on.map(|v| self.created_on.replace(v));
self.amount = index_line.amount;
self.base = index_line.base;
self.locktime = index_line.locktime;
self.conditions = index_line.conditions;
self.written_on = index_line.written_on;
}
}
......@@ -53,9 +53,9 @@ impl Sub for TxAmount {
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Deserialize, Hash, Serialize)]
pub struct TxBase(pub usize);
/// Wrap a transaction index
/// Wrap an output index
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
pub struct TxIndex(pub usize);
pub struct OutputIndex(pub usize);
/// Wrap a transaction input
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
......@@ -63,7 +63,7 @@ pub enum TransactionInput {
/// Universal Dividend Input
D(TxAmount, TxBase, PubKey, BlockNumber),
/// Previous Transaction Input
T(TxAmount, TxBase, Hash, TxIndex),
T(TxAmount, TxBase, Hash, OutputIndex),
}
impl ToString for TransactionInput {
......@@ -103,7 +103,7 @@ impl TransactionInput {
TxAmount(inner_rules.next().unwrap().as_str().parse().unwrap()),
TxBase(inner_rules.next().unwrap().as_str().parse().unwrap()),
Hash::from_hex(inner_rules.next().unwrap().as_str()).unwrap(),
TxIndex(inner_rules.next().unwrap().as_str().parse().unwrap()),
OutputIndex(inner_rules.next().unwrap().as_str().parse().unwrap()),
)
}
_ => fatal_error!("unexpected rule: {:?}", tx_input_type_pair.as_rule()), // Grammar ensures that we never reach this line
......@@ -156,7 +156,7 @@ impl FromStr for TransactionInput {
TxAmount(amount.parse().expect("fail to parse input amount")),
TxBase(base.parse().expect("fail to parse base amount")),
Hash::from_hex(tx_hash).expect("fail to parse tx_hash"),
TxIndex(tx_index.parse().expect("fail to parse tx_index amount")),
OutputIndex(tx_index.parse().expect("fail to parse tx_index amount")),
))
} else {
println!("Fail to parse this input = {:?}", source);
......@@ -1038,7 +1038,7 @@ mod tests {
TxBase(0),
Hash::from_hex("2CF1ACD8FE8DC93EE39A1D55881C50D87C55892AE8E4DB71D4EBAB3D412AA8FD")
.unwrap(),
TxIndex(1),
OutputIndex(1),
)],
unlocks: &vec![
TransactionInputUnlocks::from_str("0:SIG(0)").expect("fail to parse unlock !")
......
......@@ -12,6 +12,7 @@ path = "src/lib.rs"
[dependencies]
dubp-block-doc = { path = "../../../dubp/block-doc"} #, version = "0.1.0" }
dubp-common-doc = { path = "../../../dubp/common-doc"} #, version = "0.1.0" }
dubp-indexes = { path = "../../../dubp/indexes"} #, version = "0.1.0" }
dup-crypto = { path = "../../../crypto" }
dubp-currency-params = { path = "../../../dubp/currency-params" }
dubp-user-docs= { path = "../../../dubp/user-docs" }
......
......@@ -13,10 +13,8 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use dubp_common_doc::BlockNumber;
use dubp_indexes::sindex::UniqueIdUTXOv10;
use dubp_user_docs::documents::transaction::*;
use dup_crypto::hashs::Hash;
use dup_crypto::keys::PubKey;
use durs_common_tools::fatal_error;
use std::cmp::Ordering;
use std::ops::{Add, Sub};
......@@ -77,16 +75,12 @@ impl Sub for SourceAmount {
}
}
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
/// UTXOIndexV10
pub struct UTXOIndexV10(pub Hash, pub TxIndex);
/// UTXO content V10
pub type UTXOContentV10 = TransactionOutput;
#[derive(Debug, Clone, Deserialize, Serialize)]
/// V10 Unused Transaction Output
pub struct UTXOV10(pub UTXOIndexV10, pub UTXOContentV10);
pub struct UTXOV10(pub UniqueIdUTXOv10, pub UTXOContentV10);
impl UTXOV10 {
/// UTXO conditions
......@@ -124,12 +118,3 @@ impl UTXO {
}
}
}
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
/// Index of a V10 source