vectors

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package vectors sists in internal because it also contains code to produce bad/invalid messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bad

type Bad struct {
	Description string

	Cases []BadCase
}

Bad vector file has a bunch of different cases. each containing a list of entries of a single author feed.

type BadCase

type BadCase struct {
	Description string

	Metadata []interface{} `json:",omitempty"`
	Entries  []EntryBad
}

BadCase describes a single case with a list of entries

type EntryBad

type EntryBad struct {
	// EncodedData holds the bencode data as a hex string
	EncodedData HexString

	// Invalid denotes if a message is valid ot not.
	// sometimes we need a valid message preceeding an invalid one.
	// if message:2 has an invalid previous, for example.
	Invalid bool

	// if invalid, why the data is bad
	Reason string
}

EntryBad is a signle message in a case In the bad entries we just care if a message is broken or not. To cleanly check the contents of a message we have the Good vectors.

type EntryGood

type EntryGood struct {
	// EncodedData holds the bencode data as a hex string
	EncodedData HexString

	Key refs.MessageRef

	Author           refs.FeedRef
	Sequence         int32
	Previous         *refs.MessageRef
	Timestamp        int64
	HighlevelContent interface{}
	Signature        HexString
}

EntryGood describes a single message

type Good

type Good struct {
	// Description describes what this vector file is about
	Description string

	// Metadata holds additional values that are needed to recreate the entries
	Metadata []interface{} `json:",omitempty"`

	// Entries are the single messages on a feed
	Entries []EntryGood
}

Good is the scaffolding for the whole vector file It's called good because all the entries are valid messages.

type HexMetadata

type HexMetadata struct {
	Name      string
	HexString HexString
}

HexMetadata is a general purpose metadata field that hex encodes some data

type HexString

type HexString []byte

HexString can be used to turn a byteslice into a JSON hexadecimal string

func (HexString) MarshalJSON

func (s HexString) MarshalJSON() ([]byte, error)

MarshalJSON turns the binary data into a hex string

func (*HexString) UnmarshalJSON

func (s *HexString) UnmarshalJSON(data []byte) error

UnmarshalJSON expects data to be a string with hexadecimal bytes inside

type SubfeedAuthor

type SubfeedAuthor struct {
	Name string
	Feed refs.FeedRef
}

SubfeedAuthor can be used as metadata to signal a feed reference (@abcdefg.something)

Jump to

Keyboard shortcuts

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