ombwire

package
v0.0.0-...-5da9300 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2016 License: GPL-2.0 Imports: 12 Imported by: 1

README

Protocol Buffers

We use google protocol buffers to encode data in output scripts of bitcoin transactions.

This gives us a language agnostic specification

To contribute to this project or build tools for it. You need a protocol buffer extension for the langauge you are operating in.

For golang the compiler was retreived from here. The file types.pb.go was built using this command:

> protoc --go_out=./ types.proto

If you want to build all of the langauges supported then run:

> make

Documentation

Overview

Package ombwire is a generated protocol buffer package.

The package output for go is wirerecord

It is generated from these files:

types.proto

It has these top-level messages:

Bulletin
Location
Endorsement

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxRecordLength uint64 = 75000 // Records can be up to 75KB in size.

	// The delimiter that sits at the front of every bulletin.
	Magic = [6]byte{
		0x4f, 0x4d, 0x42, 0x55, 0x44, 0x53,
	}

	// The magic bytes that determine the type of the recorded when it is
	// encoded or decoded.
	BulletinMagic    byte = 0x01
	EndorsementMagic byte = 0x02

	ErrRecordTooBig error = errors.New("record size too big")
	ErrBadWireType  error = errors.New("No such record type")
)

Functions

func DecodeWireType

func DecodeWireType(b []byte) (proto.Message, error)

func EncodeWireType

func EncodeWireType(m proto.Message) ([]byte, error)

func HasMagic

func HasMagic(tx *wire.MsgTx) bool

HasMagic takes the passed TX and determines if it has the magic bytes associated with Ombuds. This method only looks for the leading bytes, it does not assert anything about the protocol buffers within.

func ParseTx

func ParseTx(tx *wire.MsgTx) (interface{}, error)

Types

type Bulletin

type Bulletin struct {
	Message          *string   `protobuf:"bytes,1,req,name=message" json:"message,omitempty"`
	Timestamp        *uint64   `protobuf:"varint,2,req,name=timestamp" json:"timestamp,omitempty"`
	Location         *Location `protobuf:"bytes,3,opt,name=location" json:"location,omitempty"`
	XXX_unrecognized []byte    `json:"-"`
}

A simple message with a timestamp and an optional location tag.

func NewBulletin

func NewBulletin(msg string, ts uint64, loc *Location) *Bulletin

Passed location can be nil.

func NewBulletinFromStr

func NewBulletinFromStr(msg string) *Bulletin

func (*Bulletin) GetLocation

func (m *Bulletin) GetLocation() *Location

func (*Bulletin) GetMessage

func (m *Bulletin) GetMessage() string

func (*Bulletin) GetTimestamp

func (m *Bulletin) GetTimestamp() uint64

func (*Bulletin) ProtoMessage

func (*Bulletin) ProtoMessage()

func (*Bulletin) Reset

func (m *Bulletin) Reset()

func (*Bulletin) String

func (m *Bulletin) String() string

func (*Bulletin) TxOuts

func (bltn *Bulletin) TxOuts(toBurn int64, net *chaincfg.Params) ([]*wire.TxOut, error)

Converts a bulletin into public key scripts for encoding

type Endorsement

type Endorsement struct {
	Bid              []byte  `protobuf:"bytes,1,req,name=bid" json:"bid,omitempty"`
	Timestamp        *uint64 `protobuf:"varint,2,req,name=timestamp" json:"timestamp,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

A record indicating approval, support of, or interest in a specific bulletin.

func (*Endorsement) GetBid

func (m *Endorsement) GetBid() []byte

func (*Endorsement) GetTimestamp

func (m *Endorsement) GetTimestamp() uint64

func (*Endorsement) ProtoMessage

func (*Endorsement) ProtoMessage()

func (*Endorsement) Reset

func (m *Endorsement) Reset()

func (*Endorsement) String

func (m *Endorsement) String() string

type Location

type Location struct {
	Lat              *float64 `protobuf:"fixed64,1,req,name=lat" json:"lat,omitempty"`
	Lon              *float64 `protobuf:"fixed64,2,req,name=lon" json:"lon,omitempty"`
	H                *float64 `protobuf:"fixed64,3,req,name=h" json:"h,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

A single WGS84 Datum

func NewLocation

func NewLocation(lat, lon, h float64) *Location

func (*Location) GetH

func (m *Location) GetH() float64

func (*Location) GetLat

func (m *Location) GetLat() float64

func (*Location) GetLon

func (m *Location) GetLon() float64

func (*Location) ProtoMessage

func (*Location) ProtoMessage()

func (*Location) Reset

func (m *Location) Reset()

func (*Location) String

func (m *Location) String() string

Directories

Path Synopsis
package peg contains the binary data for the first block in the public record.
package peg contains the binary data for the first block in the public record.

Jump to

Keyboard shortcuts

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