ripple

package module
v0.0.0-...-34ce12b Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2014 License: MIT Imports: 9 Imported by: 0

README

ripple

A Go library for robustly tracking transactions on the ripple network.

Build Status

Features

This library allows you to subscribe to transactions starting at any arbitrary ledger index. Since the ripple API doesn't currently support this functionality, it will request individual ledgers until it has caught up with the ledger stream. If the server connection is dropped or times out, it will re-establish a connection to a different server and request any ledgers it missed.

Ledgers are emitted in order, and contain all of their transactions. This makes it ideal for robustly tracking transactions. Your application must simply persist the latest ledger index as it consumes them. When your application restarts, it can request to start exactly where it left off.

Usage

package main

import "fmt"
import "github.com/lukecyca/ripple"

func main() {
    var r = ripple.NewMonitor(5008254)

    for {
        ledger := <-r.Ledgers()
        fmt.Printf("Ledger %s with %d transactions:\n", ledger.Index, len(ledger.Transactions))
        for _, txn := range ledger.Transactions {
            fmt.Printf("  %s %s\n", txn.Hash, txn.TransactionType)
        }
    }
}

Documentation

Index

Constants

View Source
const Timeout = time.Minute

Variables

View Source
var URIs []string = []string{
	"wss://s-west.ripple.com:443",
	"wss://s-east.ripple.com:443",
	"wss://s1.ripple.com:443",
}

Functions

This section is empty.

Types

type Amount

type Amount struct {
	Currency string
	Issuer   string
	Value    big.Rat
}

func (*Amount) UnmarshalJSON

func (a *Amount) UnmarshalJSON(b []byte) (err error)

type Connection

type Connection struct {
	Ledgers chan *Ledger
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(uri string) (c *Connection, err error)

func (*Connection) GetLedger

func (c *Connection) GetLedger(idx uint64) (err error)

type Info

type Info struct {
	BuildVersion string `json:"build_version"`
	HostID       string
	Peers        int
}

type Ledger

type Ledger struct {
	Accepted     bool
	CloseTime    Time `json:"close_time"`
	Closed       bool
	Hash         string
	Index        string `json:"ledger_index"`
	ParentHash   string
	Transactions []*Transaction
}

type LedgerEmitter

type LedgerEmitter interface {
	Ledgers() chan *Ledger
}

type Message

type Message struct {
	Id           int
	Type         string
	Result       *Result
	Status       string
	Error        string
	LedgerHash   string `json:"ledger_hash"`
	LedgerIndex  uint64 `json:"ledger_index"`
	LedgerTime   Time   `json:"ledger_time"`
	Transaction  *Transaction
	TxnCount     int    `json:"txn_count"`
	ServerStatus string `json:"server_status"`
	Validated    bool
	Meta         *Meta `json:"meta"`
}

type Meta

type Meta struct {
	TransactionResult string
}

type Monitor

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

func NewMonitor

func NewMonitor(startLedgerIdx uint64) *Monitor

func (Monitor) Ledgers

func (m Monitor) Ledgers() chan *Ledger

type Result

type Result struct {
	Ledger *Ledger
	Info   *Info
}

type Time

type Time struct {
	time.Time
}

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

type Transaction

type Transaction struct {
	Account         string
	Amount          Amount
	Date            Time
	Destination     string
	DestinationTag  uint32
	Fee             string
	Flags           uint32
	Hash            string
	SendMax         *Amount
	Sequence        uint32
	SingingPubKey   string
	TransactionType string
	TxnSignature    string

	Meta *Meta `json:"metaData"`
}

Jump to

Keyboard shortcuts

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