whisper

package
v0.8.6-0...-0fd6a22 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2015 License: LGPL-2.1-or-later Imports: 17 Imported by: 0

Documentation

Overview

Package whisper implements the Whisper PoC-1.

(https://github.com/ethereum/wiki/wiki/Whisper-PoC-1-Protocol-Spec)

Whisper combines aspects of both DHTs and datagram messaging systems (e.g. UDP). As such it may be likened and compared to both, not dissimilar to the matter/energy duality (apologies to physicists for the blatant abuse of a fundamental and beautiful natural principle).

Whisper is a pure identity-based messaging system. Whisper provides a low-level (non-application-specific) but easily-accessible API without being based upon or prejudiced by the low-level hardware attributes and characteristics, particularly the notion of singular endpoints.

Index

Constants

View Source
const (
	DefaultPow = 50 * time.Millisecond
)
View Source
const DefaultTtl = 50 * time.Second

Variables

This section is empty.

Functions

func NewPeer

func NewPeer(host *Whisper, p *p2p.Peer, ws p2p.MsgReadWriter) *peer

func Topics

func Topics(data [][]byte) [][]byte

Returns a formatted topics byte slice. data: unformatted data (e.g., no hashes needed)

func TopicsFromString

func TopicsFromString(data ...string) [][]byte

Types

type Envelope

type Envelope struct {
	Expiry uint32 // Whisper protocol specifies int32, really should be int64
	Ttl    uint32 // ^^^^^^
	Topics [][]byte
	Data   []byte
	Nonce  uint32
	// contains filtered or unexported fields
}

func NewEnvelope

func NewEnvelope(ttl time.Duration, topics [][]byte, data *Message) *Envelope

func (*Envelope) DecodeRLP

func (self *Envelope) DecodeRLP(s *rlp.Stream) error

func (*Envelope) Hash

func (self *Envelope) Hash() Hash

func (*Envelope) Open

func (self *Envelope) Open(prv *ecdsa.PrivateKey) (msg *Message, err error)

func (*Envelope) RlpData

func (self *Envelope) RlpData() interface{}

func (*Envelope) Seal

func (self *Envelope) Seal(pow time.Duration)

type Filter

type Filter struct {
	To     *ecdsa.PublicKey
	From   *ecdsa.PublicKey
	Topics [][]byte
	Fn     func(*Message)
}

type Hash

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

MOVE ME

var EmptyHash Hash

func H

func H(hash []byte) Hash

func HS

func HS(hash string) Hash

func (Hash) Compare

func (self Hash) Compare(other Hash) int

type Message

type Message struct {
	Flags     byte
	Signature []byte
	Payload   []byte
	Sent      int64

	To *ecdsa.PublicKey
}

func NewMessage

func NewMessage(payload []byte) *Message

func (*Message) Bytes

func (self *Message) Bytes() []byte

func (*Message) Encrypt

func (self *Message) Encrypt(to *ecdsa.PublicKey) (err error)

func (*Message) Recover

func (self *Message) Recover() *ecdsa.PublicKey

func (*Message) Seal

func (self *Message) Seal(pow time.Duration, opts Opts) (*Envelope, error)

type MessageEvent

type MessageEvent struct {
	To      *ecdsa.PrivateKey
	From    *ecdsa.PublicKey
	Message *Message
}

type Opts

type Opts struct {
	From   *ecdsa.PrivateKey
	To     *ecdsa.PublicKey
	Ttl    time.Duration
	Topics [][]byte
}

type Whisper

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

func New

func New() *Whisper

func (*Whisper) GetIdentity

func (self *Whisper) GetIdentity(key *ecdsa.PublicKey) *ecdsa.PrivateKey

func (*Whisper) HasIdentity

func (self *Whisper) HasIdentity(key *ecdsa.PublicKey) bool

func (*Whisper) Messages

func (self *Whisper) Messages(id int) (messages []*Message)

func (*Whisper) NewIdentity

func (self *Whisper) NewIdentity() *ecdsa.PrivateKey

func (*Whisper) Protocol

func (self *Whisper) Protocol() p2p.Protocol

func (*Whisper) Send

func (self *Whisper) Send(envelope *Envelope) error

func (*Whisper) Start

func (self *Whisper) Start()

func (*Whisper) Stop

func (self *Whisper) Stop()

func (*Whisper) Unwatch

func (self *Whisper) Unwatch(id int)

func (*Whisper) Watch

func (self *Whisper) Watch(opts Filter) int

Jump to

Keyboard shortcuts

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