(See parent doc)
Principally, the pallet focuses around storing "Documents" - data that groups an author, a hash representing the content, and a version number.
pub fn create(
origin: OriginFor<T>,
// Hash of the text of the document
text_hash: T::Hash
) -> DispatchResult
pub fn update(
origin: OriginFor<T>,
document_id: u32,
text_hash: T::Hash
) -> DispatchResult
pub fn delete(origin: OriginFor<T>, document_id: DocumentId) -> DispatchResult
/// A representation of a stored versioned document
pub struct VersionedDocument<AccountId, Hash> {
version: u16,
author: AccountId,
text_hash: Hash
}
#[pallet::storage]
#[pallet::getter(fn get_document_id)]
pub(super) type NextDocumentId<T> = StorageValue<_, u32, ValueQuery>;
#[pallet::storage]
#[pallet::getter(fn get_document)]
pub(super) type Documents<T: Config> = StorageMap<_, Blake2_128Concat, u32, VersionedDocument<T::AccountId, T::Hash>, OptionQuery>;
#[pallet::storage]
#[pallet::getter(fn get_by_text_hash)]
/// Storage that stores by text hash, for checking if a document has been submitted
pub(super) type DocumentIdsByHash<T: Config> = StorageMap<_, Blake2_128Concat, T::Hash, u32, OptionQuery>;
The pallet is intended for broader use. It may take some investigation, but it's possible the pallet could be used with some of the other text content used on-chain.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
![image alt](https:// "title") | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | Emoji list | ||
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing