Skip to content

Commit bf3be5f

Browse files
author
Joshua Mir
committed
implement submit_attestation
1 parent 644eead commit bf3be5f

File tree

1 file changed

+13
-1
lines changed
  • datdot-node/pallets/datdot/src

1 file changed

+13
-1
lines changed

datdot-node/pallets/datdot/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,19 @@ decl_module!{
688688
attestation: Attestation
689689
) {
690690
let attestor = ensure_signed(origin)?;
691-
//TODO
691+
let attestor_index = <UserIndices<T>>::get(attestor);
692+
let mut hosted_archive = <HostedMap>::get(hoster_index, dat_index);
693+
let challenge = hosted_archive.state.get(&chunk_index);
694+
match challenge {
695+
Some(Challenge::Attesting(ats)) => {
696+
let mut attestations = ats.clone();
697+
attestations.completed.push((attestor_index, attestation));
698+
hosted_archive.state.insert(chunk_index, Challenge::Attesting(attestations));
699+
<HostedMap>::insert(hoster_index, dat_index, hosted_archive);
700+
},
701+
_ => fail!(Error::<T>::InvalidChallenge),
702+
703+
}
692704
}
693705

694706
#[weight = (100000, Operational, Pays::No)] //todo weight

0 commit comments

Comments
 (0)