message

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 18 Imported by: 1

Documentation

Overview

Package message contains abstract verification and publish helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenPublishLog

func OpenPublishLog(receiveLog margaret.Log, authorLogs multilog.MultiLog, kp ssb.KeyPair, opts ...PublishOption) (ssb.Publisher, error)

OpenPublishLog needs the base datastore (root or receive log - offset2) and the userfeeds with all the sublog and uses the passed keypair to find the corresponding user feed the returned log's append function is then used to create new messages. these messages are constructed in the legacy SSB way: The poured object is JSON v8-like pretty printed and then NaCL signed, then it's pretty printed again (now with the signature inside the message) to construct it's SHA256 hash, which is used to reference it (by replys and it's previous)

func ValidateNext

func ValidateNext(current, next refs.Message) error

ValidateNext checks the author stays the same across the feed, that he previous hash is correct and that the sequence number is increasing correctly TODO: move all the message's publish and drains to it's own package

Types

type CommonArgs

type CommonArgs struct {
	Keys   bool `json:"keys"` // can't omit this falsy value, the JS-stack stack assumes true if it's not there
	Values bool `json:"values,omitempty"`
	Live   bool `json:"live,omitempty"`

	Private bool `json:"private,omitempty"`
}

type CreateHistArgs

type CreateHistArgs struct {
	CommonArgs
	StreamArgs

	ID  refs.FeedRef `json:"id,omitempty"`
	Seq int64        `json:"seq,omitempty"`

	AsJSON bool `json:"asJSON,omitempty"`
}

CreateHistArgs defines the query parameters for the createHistoryStream rpc call

func NewCreateHistoryStreamArgs added in v0.2.1

func NewCreateHistoryStreamArgs() CreateHistArgs

type CreateLogArgs

type CreateLogArgs struct {
	CommonArgs
	StreamArgs

	Seq int64 `json:"seq"`
}

CreateLogArgs defines the query parameters for the createLogStream rpc call

type MargaretSaver

type MargaretSaver struct {
	margaret.Log
}

func (MargaretSaver) Save

func (ms MargaretSaver) Save(msg refs.Message) error

type MessagesByTypeArgs

type MessagesByTypeArgs struct {
	CommonArgs
	StreamArgs

	Type string `json:"type"`
}

MessagesByTypeArgs defines the query parameters for the messagesByType rpc call

type PublishOption

type PublishOption func(*publishLog) error

func SetHMACKey

func SetHMACKey(hmackey *[32]byte) PublishOption

func UseNowTimestamps

func UseNowTimestamps(yes bool) PublishOption

type RoundedInteger added in v0.2.1

type RoundedInteger int64

RoundedInteger also accepts unmarshaling from a float

func (*RoundedInteger) UnmarshalJSON added in v0.2.1

func (ri *RoundedInteger) UnmarshalJSON(input []byte) error

type SaveMessager

type SaveMessager interface {
	Save(refs.Message) error
}

type SequencedVerificationSink added in v0.2.1

type SequencedVerificationSink interface {
	margaret.Seqer

	Verify([]byte) error
}

func NewVerifySink

func NewVerifySink(who refs.FeedRef, latest refs.Message, saver SaveMessager, hmacKey *[32]byte) (SequencedVerificationSink, error)

NewVerifySink returns a sink that does message verification and appends corret messages to the passed log. it has to be used on a feed by feed bases, the feed format is decided by the passed feed reference. TODO: start and abs could be the same parameter TODO: needs configuration for hmac and what not.. => maybe construct those from a (global) ref register where all the suffixes live with their corresponding network configuration?

type StreamArgs

type StreamArgs struct {
	Limit int64 `json:"limit,omitempty"`

	Gt RoundedInteger `json:"gt,omitempty"`
	Lt RoundedInteger `json:"lt,omitempty"`

	Reverse bool `json:"reverse,omitempty"`
}

func NewStreamArgs added in v0.2.1

func NewStreamArgs() StreamArgs

type TanglesArgs

type TanglesArgs struct {
	CommonArgs
	StreamArgs

	Root refs.MessageRef `json:"root"`

	// indicate the v2 subtangle (group, ...)
	// empty string for v1 tangle
	Name string `json:"name"`
}

type VerificationRouter added in v0.2.1

type VerificationRouter struct {
	// contains filtered or unexported fields
}

VerificationRouter hands out sinks (or drains) to pour messages into for verification and storage

func NewVerificationRouter added in v0.2.1

func NewVerificationRouter(rxlog margaret.Log, feeds multilog.MultiLog, hmacSec *[32]byte) (*VerificationRouter, error)

NewVerificationRouter supplies a unique drain per author that skip duplicate messages

func (*VerificationRouter) CloseSink added in v0.2.1

func (vs *VerificationRouter) CloseSink(ref refs.FeedRef)

func (*VerificationRouter) GetSink added in v0.2.1

func (vs *VerificationRouter) GetSink(ref refs.FeedRef, complete bool) (SequencedVerificationSink, error)

GetSink returns a verification sink for that author. If called twice for the same author it returns the same drink (for deduplication)

type WhoamiReply

type WhoamiReply struct {
	ID refs.FeedRef `json:"id"`
}

Directories

Path Synopsis
Package legacy how to encode and verify the current ssb messages.
Package legacy how to encode and verify the current ssb messages.
Package multimsg implements a margaret codec to encode multiple kinds of messages to disk.
Package multimsg implements a margaret codec to encode multiple kinds of messages to disk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL