node

package
v0.0.0-...-6a013f7 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is an LRU cache, safe for concurrent access.

func NewCache

func NewCache(maxEntries int) *Cache

New returns a new cache with the provided maximum items.

func (*Cache) Add

func (c *Cache) Add(key, value interface{})

Add adds the provided key and value to the cache, evicting an old item if necessary.

func (*Cache) Get

func (c *Cache) Get(key interface{}) (value interface{}, ok bool)

Get fetches the key's value from the cache. The ok result will be true if the item was found.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest() (key, value interface{})

RemoveOldest removes the oldest item in the cache and returns its key and value. If the cache is empty, the empty string and nil are returned.

type Conf

type Conf struct {
	HttpHost           string
	UdpHost            string
	TcpHost            string
	DbPath             string
	Debug              bool
	Testnet            bool
	Neighbors          MultiString
	MinWeightMagnitude int
}

type Http

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

func NewHttp

func NewHttp(host string) *Http

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

func NewNullLogger

func NewNullLogger() Logger

type Message

type Message struct {
	TxBytes           []byte // Raw transaction bytes
	TxTrits           []int8 // Raw transaction trits
	Address           []int8 // Address trits
	Trunk             []int8 // Trunk address trits
	Branch            []int8 // Branch address trits
	Bundle            []int8 // Bundle address trits
	Tag               []int8 // Tag
	ObsoleteTag       []int8
	Nonce             []int8 // Nonce
	ValueTrailer      []int8 // Trits after usable value
	AttachmentTs      int64  // Attachment timestamp
	AttachmentTsUpper int64  // Attachment timestamp upper bound
	AttachmentTsLower int64  // Attachment timestamp lower bound
	Value             int64  // Transaction value
	Ts                int64
	CurrentIndex      int64
	LastIndex         int64
	Trailer           []byte // UDP packet trailer. Only set if message was read with ParseUdpBytes.
	// contains filtered or unexported fields
}

func ParseTxBytes

func ParseTxBytes(b []byte) (*Message, error)

ParseTxBytes parses transaction bytes without an UDP trailer.

func ParseUdpBytes

func ParseUdpBytes(b []byte) (*Message, error)

ParseUdpBytes parses a transaction including UDP trailer bytes.

func (Message) AddressTrytes

func (m Message) AddressTrytes() string

func (Message) BranchTrytes

func (m Message) BranchTrytes() string

func (Message) BundleTrytes

func (m Message) BundleTrytes() string

func (*Message) Debug

func (m *Message) Debug() string

func (Message) NonceTrytes

func (m Message) NonceTrytes() string

func (Message) ObsoleteTagTrytes

func (m Message) ObsoleteTagTrytes() string

func (Message) Store

func (m Message) Store(tangle storage.Store) error

Store stores the message in the tangle. Returns an error if storage failed or the transaction already exists.

func (Message) TagTrytes

func (m Message) TagTrytes() string

func (*Message) TrailerHash

func (m *Message) TrailerHash() []int8

func (Message) TrunkTrytes

func (m Message) TrunkTrytes() string

func (*Message) TxDigest

func (m *Message) TxDigest() []byte

func (Message) TxDigestHex

func (m Message) TxDigestHex() string

func (*Message) TxHash

func (m *Message) TxHash() []int8

func (Message) Validate

func (m Message) Validate(minWeightMag int) error

type MultiString

type MultiString []string

func (*MultiString) Set

func (m *MultiString) Set(value string) error

func (MultiString) String

func (m MultiString) String() string

type Node

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

func New

func New(conf Conf, store storage.Store, logger Logger) *Node

func (*Node) Serve

func (node *Node) Serve() error

func (*Node) Shutdown

func (node *Node) Shutdown() error

type UDP

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

func NewUDP

func NewUDP(host string, minWeightMag int, logger Logger, store storage.Store) *UDP

func (*UDP) Close

func (udp *UDP) Close()

func (*UDP) Listen

func (udp *UDP) Listen() error

Jump to

Keyboard shortcuts

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