types

package
v0.0.0-...-9dedc5b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Thrower 来自丢瓶方
	Thrower from = 0
	// Replier 来自回应方
	Replier from = 1
)

Variables

This section is empty.

Functions

func GetMessageKey

func GetMessageKey(bottleID uuid.UUID, msgID uint16) []byte

GetMessageKey 获取消息建

Types

type Bottle

type Bottle struct {
	ID      uuid.UUID
	Thrower [32]byte //扔瓶者的加密公钥
	//Messages         []Message // leveldb的k-v模式(顺序读效率不高)不适合relationship
	Title       string   //塞入的第一条消息
	MessagesNum uint16   //瓶中消息数量
	Replier     [32]byte //回应者的加密公钥
}

Bottle 漂流瓶

func (*Bottle) GetKey

func (bottle *Bottle) GetKey() []byte

GetKey 获取实体键

type IPayload

type IPayload interface {
	GetKey() []byte
	// contains filtered or unexported methods
}

IPayload 接口

type Message

type Message struct {
	ID       uint16
	BottleID uuid.UUID
	Data     []byte
	From     from
}

Message 消息,每个漂流瓶里有至少一条消息

func (*Message) GetKey

func (msg *Message) GetKey() []byte

GetKey 获取消息键

type Transx

type Transx struct {
	Signature  []byte //发送方对这个消息的私钥签名
	SendTime   *time.Time
	SignPubKey crypto.PubKey
	Payload    IPayload
}

Transx 事务基类

func (*Transx) Sign

func (cmu *Transx) Sign(privKey crypto.PrivKey) error

Sign 给消息签名 privKey:发送方私钥

func (*Transx) Verify

func (cmu *Transx) Verify() bool

Verify 校验消息是否未被篡改

Jump to

Keyboard shortcuts

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