Expand description
Contract moderation: the declaration, inside a data contract’s config, that the contract keeps a banlist, a suspension list and/or a warning list of identities, and who may edit them.
An identity on the banlist, or on the suspension list with a suspension that has not lapsed,
cannot act on the contract at the document level: every document transition it signs against
the contract is refused. Token transitions are not affected. A warning bars nothing: it is
a record, with a reason and a time, that the identity and everyone else can read, and that
accumulates until a moderator clears it. The lists live under the contract’s own subtree in
Drive (keys 128, 192 and 224 of its other tree, [64, id, 2]) and are edited by the
ContractUserModeration state transition.
The same moderators may delete the documents of the document types that say so
(moderatorAbilities.delete), and write the fields a document type keeps for them
(moderatorAbilities.changeFields), with the same transition. Each removal leaves a
ContractDocumentRemoval under the contract (key 16 of its other tree).
A contract may instead declare that its moderators are an elected team: until one is seated, the interim moderators the declaration names moderate as the merged kinds do, or nobody does and the moderated document types wait.
Re-exports§
pub use elected::ElectedModerators;pub use elected::InterimModerators;pub use elected::ModerationAbility;pub use elected::DEFAULT_ELECTION_WINDOW_SECONDS;
Modules§
- elected
- Elected moderation: the declaration that a contract’s moderators are a team chosen by masternodes and evonodes instead of by the contract owner (protocol version 14).
Structs§
- Contract
Ban - A banlist entry.
- Contract
Document Removal - The record a contract keeps of a document one of its moderators deleted.
- Contract
Document Restoration - The mark a restore leaves on a removal record: who brought the document back, and when.
- Contract
Moderation Config - The moderation a data contract declares in its config.
- Contract
Moderation Document - A document a moderation reason is about, named by its document type and its id.
- Contract
Moderation List Statuses - One identity’s status on the lists that were read, one entry per list, in the order read: what a status query answers for the lists it names, and what the proof of a moderation transition’s execution shows. A list the query did not name is absent, not empty: an identity that is not suspended may still be banned when the banlist was not read. Query every list the contract keeps for the whole picture.
- Contract
Moderation Reason - Why a moderator banned, suspended or warned an identity, or deleted a document. Every such action carries one, and it is stored with the entry or the record, so whoever reads the list reads the reason.
- Contract
Moderation Status - What a contract’s moderation lists say about one identity.
- Contract
Suspension - A suspension list entry.
- Contract
Team Action - A proposal the seated moderation team of an elected contract votes on, kept under the contract (protocol version 14): the team’s counterpart of a token group action.
- Contract
Warning - One warning of a warning list entry.
- Settled
Deletion Rule - Who must approve a moderator’s deletion of a settled document: one past the window its
document type gives its moderators (
moderatorAbilities.deleteWithin). The document type’smoderatorAbilities.deleteSettled(protocol version 14), on a contract whose moderators are an elected team: so many members of the seated team, the leader counted among them when it approves, and the leader among them only whenleaderis set; withleaderunset, any members meet it. Whileapprovers_predate_documentis set, a member the leader added counts only for documents created after its addition.
Enums§
- Contract
Moderation List - Which of the moderation lists an action or a query refers to.
- Contract
Moderation List Status - What one of a contract’s moderation lists says about one identity, and nothing about the other list. It is what the proof of a moderation transition’s execution shows: that proof holds the edited entry only, so the other list stays unknown rather than being reported as empty (an identity unsuspended a moment ago may well be banned).
- Contract
Moderators - Who may send a
ContractUserModerationtransition for the contract. - Contract
Team Action Event - What a
ContractTeamActiondoes once approved.
Functions§
- decode_
kept_ fields - Reads the values
encode_kept_fieldswrote, underdocument_type: each kept path to its value, typed as reading the document gives it, a path the document held no value at left out. Refuses bytes that end before the last path or run past it. - document_
schema_ grants_ moderator_ abilities - Whether a raw document type schema gives the contract’s moderators an ability over its documents: deleting them, or changing their moderator fields.
- document_
schema_ lets_ moderators_ change_ fields - Whether a raw document type schema lists fields only the contract’s moderators write
(a non-empty
moderatorAbilities.changeFields). - document_
schema_ lets_ moderators_ delete - Whether a raw document type schema lets the contract’s moderators delete its documents
(
moderatorAbilities.delete: true). - document_
schema_ lets_ moderators_ delete_ settled - Whether a raw document type schema lets the members of a seated moderation team delete its
documents once settled, past
deleteWithin(amoderatorAbilities.deleteSettledobject). - encode_
kept_ fields - Encodes the values a removal record keeps of
document, a document ofdocument_type(moderatorAbilities.deleteKeepsFields), the way the document encodes its properties: for each path the type lists, in the list’s order,0when the document holds no value there, or1followed by the value as an optional property of its type is written (DocumentPropertyType::encode_value_ref_with_size), an object length-prefixed with its members in order, a time or a block height as eight big-endian bytes and a core block height as four. The paths themselves are not written: the type lists them and never changes the list, so a reader knows them from the type. Empty for a type that keeps none. - kept_
value_ at - What a removal record says of
property, from the paths its document type keeps (kept_paths, itsmoderatorAbilities.deleteKeepsFields) and the values the record keeps (kept_values,ContractDocumentRemoval::kept_values):Nonewhen the record does not keep it, neither kept itself nor inside a kept object; otherwise the value,Some(None)when the document held none there. Kept paths never nest, so at most one covers it.