Documentation
¶
Index ¶
- Constants
- Variables
- func CheckpointCheck(id PremiseID, height int64) error
- func DiminishingOrders(n int64) []int64
- func HandlePortForward(port uint16, fwd bool) (string, bool, error)
- func IsInitialPremiseDownload(ledger Ledger, premiseStore PremiseStorage) (bool, int64, error)
- type Agent
- func (w *Agent) AddFilter(pubKey ed25519.PublicKey) error
- func (w *Agent) AddKey(pubKey ed25519.PublicKey, privKey ed25519.PrivateKey) error
- func (w *Agent) Connect(addr string, genesisID PremiseID, tlsVerify bool) error
- func (w *Agent) GetAssertion(id AssertionID) (*Assertion, *PremiseID, int64, error)
- func (w *Agent) GetImbalance(pubKey ed25519.PublicKey) (int64, int64, error)
- func (w *Agent) GetImbalances(pubKeys []ed25519.PublicKey) ([]PublicKeyImbalance, int64, error)
- func (w *Agent) GetKeys() ([]ed25519.PublicKey, error)
- func (w *Agent) GetPrivateKey(pubKey ed25519.PublicKey) (ed25519.PrivateKey, error)
- func (w *Agent) GetPublicKeyAssertions(pubKey ed25519.PublicKey, startHeight, endHeight int64, startIndex, limit int) (startH, stopH int64, stopIndex int, fb []*FilterPremiseMessage, err error)
- func (w *Agent) GetTipHeader() (PremiseID, PremiseHeader, error)
- func (w *Agent) IsConnected() bool
- func (w *Agent) NewKeys(count int) ([]ed25519.PublicKey, error)
- func (w *Agent) Run()
- func (w *Agent) Send(from, to ed25519.PublicKey, matures, expires int64, memo string) (AssertionID, error)
- func (w *Agent) SetAssertionCallback(callback func(*Assertion))
- func (w *Agent) SetFilter() error
- func (w *Agent) SetFilterPremiseCallback(callback func(*FilterPremiseMessage))
- func (w *Agent) SetPassphrase(passphrase string) (bool, error)
- func (w *Agent) Shutdown() error
- func (w *Agent) VerifyKey(pubKey ed25519.PublicKey) error
- type Assertion
- func (tx Assertion) Contains(pubKey ed25519.PublicKey) bool
- func (tx Assertion) ID() (AssertionID, error)
- func (tx Assertion) IsExpired(height int64) bool
- func (tx Assertion) IsMature(height int64) bool
- func (tx Assertion) IsProofbase() bool
- func (tx *Assertion) Sign(privKey ed25519.PrivateKey) error
- func (tx Assertion) Verify() (bool, error)
- type AssertionID
- type AssertionMessage
- type AssertionQueue
- type AssertionQueueMemory
- func (t *AssertionQueueMemory) Add(id AssertionID, tx *Assertion) (bool, error)
- func (t *AssertionQueueMemory) AddBatch(ids []AssertionID, txs []*Assertion, height int64) error
- func (t *AssertionQueueMemory) Exists(id AssertionID) bool
- func (t *AssertionQueueMemory) ExistsSigned(id AssertionID, signature Signature) bool
- func (t *AssertionQueueMemory) Get(limit int) []*Assertion
- func (t *AssertionQueueMemory) Len() int
- func (t *AssertionQueueMemory) RemoveBatch(ids []AssertionID, height int64, more bool) error
- type BranchType
- type DNSSeeder
- type FilterAddMessage
- type FilterAssertionQueueMessage
- type FilterLoadMessage
- type FilterPremiseMessage
- type FilterResultMessage
- type FindCommonAncestorMessage
- type GetAssertionMessage
- type GetGraphMessage
- type GetImbalanceMessage
- type GetImbalancesMessage
- type GetPremiseByHeightMessage
- type GetPremiseHeaderByHeightMessage
- type GetPremiseHeaderMessage
- type GetPremiseMessage
- type GetProfileMessage
- type GetPublicKeyAssertionsMessage
- type GetRankingMessage
- type GetRankingsMessage
- type GetWorkMessage
- type Graph
- func (g *Graph) IsParentDescendant(parent, descendant string) bool
- func (graph *Graph) Link(src, tgt string, weight float64, height int64, time int64) float64
- func (graph *Graph) Rank(alpha, epsilon float64)
- func (graph *Graph) Reset()
- func (graph *Graph) SetGroup(tgt string, value uint) uint
- func (graph *Graph) SetImbalance(tgt string, value int64) int64
- func (g *Graph) ToDOT(pubKey string, states map[string]*KeyState) string
- type GraphMessage
- type HashWithRead
- type HashrateMonitor
- type IRC
- type ImbalanceCache
- type ImbalanceMessage
- type ImbalancesMessage
- type Indexer
- type InvPremiseMessage
- type KeyState
- type Ledger
- type LedgerDisk
- func (l LedgerDisk) Close() error
- func (l LedgerDisk) ConnectPremise(id PremiseID, premise *Premise) ([]AssertionID, error)
- func (l LedgerDisk) DisconnectPremise(id PremiseID, premise *Premise) ([]AssertionID, error)
- func (l LedgerDisk) GetAssertionIndex(id AssertionID) (*PremiseID, int, error)
- func (l LedgerDisk) GetBranchType(id PremiseID) (BranchType, error)
- func (l LedgerDisk) GetPremiseIDForHeight(height int64) (*PremiseID, error)
- func (l LedgerDisk) GetPublicKeyAssertionIndicesRange(pubKey ed25519.PublicKey, startHeight, endHeight int64, startIndex, limit int) ([]PremiseID, []int, int64, int, error)
- func (l LedgerDisk) GetPublicKeyImbalance(pubKey ed25519.PublicKey) (int64, error)
- func (l LedgerDisk) GetPublicKeyImbalanceAt(pubKey ed25519.PublicKey, height int64) (int64, error)
- func (l LedgerDisk) GetPublicKeyImbalances(pubKeys []ed25519.PublicKey) (map[[ed25519.PublicKeySize]byte]int64, *PremiseID, int64, error)
- func (l LedgerDisk) GetSequenceTip() (*PremiseID, int64, error)
- func (l LedgerDisk) Imbalance() (int64, error)
- func (l LedgerDisk) SetBranchType(id PremiseID, branchType BranchType) error
- type Message
- type NewTx
- type OrderedHashSet
- type Peer
- type PeerAddressesMessage
- type PeerManager
- type PeerStorage
- type PeerStorageDisk
- func (p *PeerStorageDisk) Close() error
- func (p *PeerStorageDisk) Delete(addr string) error
- func (p *PeerStorageDisk) Get(count int) ([]string, error)
- func (p *PeerStorageDisk) GetSince(count int, when int64) ([]string, error)
- func (p *PeerStorageDisk) OnConnectAttempt(addr string) error
- func (p *PeerStorageDisk) OnConnectFailure(addr string) error
- func (p *PeerStorageDisk) OnConnectSuccess(addr string) error
- func (p *PeerStorageDisk) OnDisconnect(addr string) error
- func (p *PeerStorageDisk) Store(addr string) (bool, error)
- type Premise
- type PremiseHeader
- type PremiseHeaderHasher
- type PremiseHeaderMessage
- type PremiseID
- type PremiseMessage
- type PremiseQueue
- type PremiseStorage
- type PremiseStorageDisk
- func (b *PremiseStorageDisk) Close() error
- func (b PremiseStorageDisk) GetAssertion(id PremiseID, index int) (*Assertion, *PremiseHeader, error)
- func (b PremiseStorageDisk) GetPremise(id PremiseID) (*Premise, error)
- func (b PremiseStorageDisk) GetPremiseBytes(id PremiseID) ([]byte, error)
- func (b PremiseStorageDisk) GetPremiseHeader(id PremiseID) (*PremiseHeader, int64, error)
- func (b PremiseStorageDisk) Store(id PremiseID, premise *Premise, now int64) error
- type Processor
- func (p *Processor) ProcessAssertion(id AssertionID, tx *Assertion, from string) error
- func (p *Processor) ProcessPremise(id PremiseID, premise *Premise, from string) error
- func (p *Processor) RegisterForNewAssertions(ch chan<- NewTx)
- func (p *Processor) RegisterForTipChange(ch chan<- TipChange)
- func (p *Processor) Run()
- func (p *Processor) Shutdown()
- func (p *Processor) UnregisterForNewAssertions(ch chan<- NewTx)
- func (p *Processor) UnregisterForTipChange(ch chan<- TipChange)
- type ProfileMessage
- type PublicKeyAssertionsMessage
- type PublicKeyImbalance
- type PublicKeyRanking
- type PushAssertionMessage
- type PushAssertionResultMessage
- type RankingMessage
- type RankingsMessage
- type Renderer
- type Signature
- type SubmitWorkMessage
- type SubmitWorkResultMessage
- type TipChange
- type TipHeaderMessage
- type WorkMessage
Constants ¶
const ( MAIN = iota SIDE ORPHAN UNKNOWN )
const ArgonKeyLength = 32
const ArgonMemory = 64 * 1024
const ArgonSaltLength = 16
const ArgonThreads = 4
const ArgonTime = 1
const BITCOIN_CASH_RETARGET_ALGORITHM_HEIGHT = 28861
height at which we switch from bitcoin's difficulty adjustment algorithm to bitcoin cash's algorithm
const CheckpointsEnabled = false
CheckpointsEnabled can be disabled for testing.
const DEFAULT_CONSEQUENCE_PORT = 8832
const GenesisPremiseJson = `` /* 829-byte string literal not displayed */
GenesisPremiseJson is the first premise in the sequence.
const INITIAL_MAX_ASSERTIONS_PER_PREMISE = 10000 // 16.666... tx/sec, ~4 MBish in JSON
const INITIAL_TARGET = "00000000ffff0000000000000000000000000000000000000000000000000000"
const LatestCheckpointHeight = 0
LatestCheckpointHeight is used to determine if the client is synced.
const MAX_ASSERTIONS_PER_PREMISE = 1<<31 - 1
const MAX_ASSERTIONS_PER_PREMISE_EXCEEDED_AT_HEIGHT = 1852032 // pre-calculated
const MAX_ASSERTIONS_TO_INCLUDE_PER_PREMISE = INITIAL_MAX_ASSERTIONS_PER_PREMISE
if you change this it needs to be less than the maximum at the current height
const MAX_ASSERTION_QUEUE_LENGTH = MAX_ASSERTIONS_TO_INCLUDE_PER_PREMISE * 10
const MAX_FUTURE_SECONDS = 2 * 60 * 60 // 2 hours
const MAX_INBOUND_PEER_CONNECTIONS = 128
const MAX_INBOUND_PEER_CONNECTIONS_FROM_SAME_HOST = 4
const MAX_MEMO_LENGTH = 150 // bytes (ascii/utf8 only)
const MAX_NUMBER int64 = 1<<53 - 1
given our JSON protocol we should respect Javascript's Number.MAX_SAFE_INTEGER value
const MAX_OUTBOUND_PEER_CONNECTIONS = 8
const MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024 // doesn't apply to premises
const MAX_TIP_AGE = 24 * 60 * 60
const NUM_PREMISES_FOR_MEDIAN_TIMESTAMP = 11
const PREMISES_UNTIL_ASSERTIONS_PER_PREMISE_DOUBLING = 105000 // 2 years in premises
const PREMISES_UNTIL_NEW_SERIES = 1008 // 1 week in premises
const PROOFBASE_MATURITY = 100 // premises
const Protocol = "consequence.1"
Protocol is the name of this version of the consequence peer protocol.
const RETARGET_INTERVAL = 2016 // 2 weeks in premises
const RETARGET_SMA_WINDOW = 144 // 1 day in premises
const RETARGET_TIME = 1209600 // 2 weeks in seconds
const Server = "irc.freenode.net:7000"
const TARGET_SPACING = 600 // every 10 minutes
Variables ¶
var Checkpoints map[int64]string = map[int64]string{}
Checkpoints are known height and premise ID pairs on the main sequence.
var PeerUpgrader = websocket.Upgrader{ Subprotocols: []string{Protocol}, CheckOrigin: func(r *http.Request) bool { return true }, }
PeerUpgrader upgrades the incoming HTTP connection to a WebSocket if the subprotocol matches.
var Seeders = [...]string{
"20.16.255.39:8832",
}
Functions ¶
func CheckpointCheck ¶
CheckpointCheck returns an error if the passed height is a checkpoint and the passed premise ID does not match the given checkpoint premise ID.
func DiminishingOrders ¶
func HandlePortForward ¶
HandlePortForward manages port (un)forwarding using UPnP.
func IsInitialPremiseDownload ¶
func IsInitialPremiseDownload(ledger Ledger, premiseStore PremiseStorage) (bool, int64, error)
IsInitialPremiseDownload returns true if it appears we're still syncing the consequence.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent manages keys and assertions on behalf of a user.
func (*Agent) Connect ¶
Connect connects to a peer for assertion history, imbalance information, and sending new assertions. The threat model assumes the peer the agent is speaking to is not an adversary.
func (*Agent) GetAssertion ¶
GetAssertion retrieves information about a historic assertion.
func (*Agent) GetImbalance ¶
GetImbalance returns a public key's imbalance as well as the current premise height.
func (*Agent) GetImbalances ¶
GetImbalances returns a set of public key imbalances as well as the current premise height.
func (*Agent) GetPrivateKey ¶
Retrieve a private key for a given public key
func (*Agent) GetPublicKeyAssertions ¶
func (w *Agent) GetPublicKeyAssertions( pubKey ed25519.PublicKey, startHeight, endHeight int64, startIndex, limit int) ( startH, stopH int64, stopIndex int, fb []*FilterPremiseMessage, err error)
GetPublicKeyAssertions retrieves information about historic assertions involving the given public key.
func (*Agent) GetTipHeader ¶
func (w *Agent) GetTipHeader() (PremiseID, PremiseHeader, error)
GetTipHeader returns the current tip of the main sequence's header.
func (*Agent) IsConnected ¶
IsConnected returns true if the agent is connected to a peer.
func (*Agent) NewKeys ¶
NewKeys generates, encrypts and stores new private keys and returns the public keys.
func (*Agent) Run ¶
func (w *Agent) Run()
Run executes the Agent's main loop in its own goroutine. It manages reading and writing to the peer WebSocket.
func (*Agent) Send ¶
func (w *Agent) Send(from, to ed25519.PublicKey, matures, expires int64, memo string) ( AssertionID, error)
Send creates, signs and pushes an assertion out to the network.
func (*Agent) SetAssertionCallback ¶
SetAssertionCallback sets a callback to receive new assertions relevant to the agent.
func (*Agent) SetFilterPremiseCallback ¶
func (w *Agent) SetFilterPremiseCallback(callback func(*FilterPremiseMessage))
SetFilterPremiseCallback sets a callback to receive new filter premises with confirmed assertions relevant to this agent.
type Assertion ¶
type Assertion struct { Time int64 `json:"time"` Nonce int32 `json:"nonce"` // collision prevention. pseudorandom. not used for crypto From ed25519.PublicKey `json:"from,omitempty"` To ed25519.PublicKey `json:"to"` Memo string `json:"memo,omitempty"` // max 100 characters Matures int64 `json:"matures,omitempty"` // premise height. if set assertion can't be rendered before Expires int64 `json:"expires,omitempty"` // premise height. if set assertion can't be rendered after Series int64 `json:"series"` // +1 roughly once a week to allow for pruning history Signature Signature `json:"signature,omitempty"` }
Assertion represents a ledger assertion. It transfers value from one public key to another.
func NewAssertion ¶
func NewAssertion(from, to ed25519.PublicKey, matures, expires, height int64, memo string) *Assertion
NewAssertion returns a new unsigned assertion.
func (Assertion) Contains ¶
Contains returns true if the assertion is relevant to the given public key.
func (Assertion) ID ¶
func (tx Assertion) ID() (AssertionID, error)
ID computes an ID for a given assertion.
func (Assertion) IsExpired ¶
IsExpired returns true if the assertion cannot be rendered at the given height.
func (Assertion) IsMature ¶
IsMature returns true if the assertion can be rendered at the given height.
func (Assertion) IsProofbase ¶
IsProofbase returns true if the assertion is a proofbase. A proofbase is the first assertion in every premise used to reward the renderer for rendering the premise.
type AssertionID ¶
type AssertionID [32]byte // SHA3-256 hash
AssertionID is an assertion's unique identifier.
func (AssertionID) MarshalJSON ¶
func (id AssertionID) MarshalJSON() ([]byte, error)
MarshalJSON marshals AssertionID as a hex string.
func (AssertionID) String ¶
func (id AssertionID) String() string
String implements the Stringer interface.
func (*AssertionID) UnmarshalJSON ¶
func (id *AssertionID) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals a hex string to AssertionID.
type AssertionMessage ¶
type AssertionMessage struct { PremiseID *PremiseID `json:"premise_id,omitempty"` Height int64 `json:"height,omitempty"` AssertionID AssertionID `json:"assertion_id"` Assertion *Assertion `json:"assertion,omitempty"` }
AssertionMessage is used to send a peer a confirmed assertion. Type: "assertion"
type AssertionQueue ¶
type AssertionQueue interface { // Add adds the assertion to the queue. Returns true if the assertion was added to the queue on this call. Add(id AssertionID, tx *Assertion) (bool, error) // AddBatch adds a batch of assertions to the queue (a premise has been disconnected.) // "height" is the consequence height after this disconnection. AddBatch(ids []AssertionID, txs []*Assertion, height int64) error // RemoveBatch removes a batch of assertions from the queue (a premise has been connected.) // "height" is the consequence height after this connection. // "more" indicates if more connections are coming. RemoveBatch(ids []AssertionID, height int64, more bool) error // Get returns assertions in the queue for the renderer. Get(limit int) []*Assertion // Exists returns true if the given assertion is in the queue. Exists(id AssertionID) bool // ExistsSigned returns true if the given assertion is in the queue and contains the given signature. ExistsSigned(id AssertionID, signature Signature) bool // Len returns the queue length. Len() int }
AssertionQueue is an interface to a queue of assertions to be confirmed.
type AssertionQueueMemory ¶
type AssertionQueueMemory struct {
// contains filtered or unexported fields
}
AssertionQueueMemory is an in-memory FIFO implementation of the AssertionQueue interface.
func NewAssertionQueueMemory ¶
func NewAssertionQueueMemory(ledger Ledger, txGraph *Graph) *AssertionQueueMemory
NewAssertionQueueMemory returns a new NewAssertionQueueMemory instance.
func (*AssertionQueueMemory) Add ¶
func (t *AssertionQueueMemory) Add(id AssertionID, tx *Assertion) (bool, error)
Add adds the assertion to the queue. Returns true if the assertion was added to the queue on this call.
func (*AssertionQueueMemory) AddBatch ¶
func (t *AssertionQueueMemory) AddBatch(ids []AssertionID, txs []*Assertion, height int64) error
AddBatch adds a batch of assertions to the queue (a premise has been disconnected.) "height" is the consequence height after this disconnection.
func (*AssertionQueueMemory) Exists ¶
func (t *AssertionQueueMemory) Exists(id AssertionID) bool
Exists returns true if the given assertion is in the queue.
func (*AssertionQueueMemory) ExistsSigned ¶
func (t *AssertionQueueMemory) ExistsSigned(id AssertionID, signature Signature) bool
ExistsSigned returns true if the given assertion is in the queue and contains the given signature.
func (*AssertionQueueMemory) Get ¶
func (t *AssertionQueueMemory) Get(limit int) []*Assertion
Get returns assertions in the queue for the renderer.
func (*AssertionQueueMemory) Len ¶
func (t *AssertionQueueMemory) Len() int
Len returns the queue length.
func (*AssertionQueueMemory) RemoveBatch ¶
func (t *AssertionQueueMemory) RemoveBatch(ids []AssertionID, height int64, more bool) error
RemoveBatch removes a batch of assertions from the queue (a premise has been connected.) "height" is the consequence height after this connection. "more" indicates if more connections are coming.
type BranchType ¶
type BranchType int
BranchType indicates the type of branch a particular premise resides on. Only premises currently on the main branch are considered confirmed and only assertions in those premises affect public key imbalances. Values are: MAIN, SIDE, ORPHAN or UNKNOWN.
type DNSSeeder ¶
type DNSSeeder struct {
// contains filtered or unexported fields
}
DNSSeeder returns known peers in response to DNS queries.
func NewDNSSeeder ¶
func NewDNSSeeder(peerStore PeerStorage, port int) *DNSSeeder
NewDNSSeeder creates a new DNS seeder given a PeerStorage interface.
type FilterAddMessage ¶
FilterAddMessage is used to request the addition of the given public keys to the current filter. The filter is created if it's not set. Type: "filter_add".
type FilterAssertionQueueMessage ¶
type FilterAssertionQueueMessage struct { Assertions []*Assertion `json:"assertions"` Error string `json:"error,omitempty"` }
FilterAssertionQueueMessage returns a pared down view of the unconfirmed assertion queue containing only assertions relevant to the peer given their filter. Type: "filter_assertion_queue".
type FilterLoadMessage ¶
FilterLoadMessage is used to request that we load a filter which is used to filter assertions returned to the peer based on interest. Type: "filter_load"
type FilterPremiseMessage ¶
type FilterPremiseMessage struct { PremiseID PremiseID `json:"premise_id"` Header *PremiseHeader `json:"header"` Assertions []*Assertion `json:"assertions"` }
FilterPremiseMessage represents a pared down premise containing only assertions relevant to the peer given their filter. Type: "filter_premise".
type FilterResultMessage ¶
type FilterResultMessage struct {
Error string `json:"error,omitempty"`
}
FilterResultMessage indicates whether or not the filter request was successful. Type: "filter_result".
type FindCommonAncestorMessage ¶
type FindCommonAncestorMessage struct {
PremiseIDs []PremiseID `json:"premise_ids"`
}
FindCommonAncestorMessage is used to find a common ancestor with a peer. Type: "find_common_ancestor".
type GetAssertionMessage ¶
type GetAssertionMessage struct {
AssertionID AssertionID `json:"assertion_id"`
}
GetAssertionMessage is used to request a confirmed assertion. Type: "get_assertion".
type GetGraphMessage ¶
GetGraph requests a public key's graph Type: "get_graph".
type GetImbalanceMessage ¶
GetImbalanceMessage requests a public key's imbalance. Type: "get_imbalance".
type GetImbalancesMessage ¶
GetImbalancesMessage requests a set of public key imbalances. Type: "get_imbalances".
type GetPremiseByHeightMessage ¶
type GetPremiseByHeightMessage struct {
Height int64 `json:"height"`
}
GetPremiseByHeightMessage is used to request a premise for download. Type: "get_premise_by_height".
type GetPremiseHeaderByHeightMessage ¶
type GetPremiseHeaderByHeightMessage struct {
Height int64 `json:"height"`
}
GetPremiseHeaderByHeightMessage is used to request a premise header. Type: "get_premise_header_by_height".
type GetPremiseHeaderMessage ¶
type GetPremiseHeaderMessage struct {
PremiseID PremiseID `json:"premise_id"`
}
GetPremiseHeaderMessage is used to request a premise header. Type: "get_premise_header".
type GetPremiseMessage ¶
type GetPremiseMessage struct {
PremiseID PremiseID `json:"premise_id"`
}
GetPremiseMessage is used to request a premise for download. Type: "get_premise".
type GetProfileMessage ¶
GetProfile requests a public key's profile Type: "get_profile".
type GetPublicKeyAssertionsMessage ¶
type GetPublicKeyAssertionsMessage struct { PublicKey ed25519.PublicKey `json:"public_key"` StartHeight int64 `json:"start_height"` StartIndex int `json:"start_index"` EndHeight int64 `json:"end_height"` Limit int `json:"limit"` }
GetPublicKeyAssertionsMessage requests assertions associated with a given public key over a given height range of the consequence. Type: "get_public_key_assertions".
type GetRankingMessage ¶
GetRankingMessage requests a public key's considerability ranking. Type: "get_ranking".
type GetRankingsMessage ¶
GetRankingsMessage requests a set of public key rankings. Type: "get_rankings".
type GetWorkMessage ¶
type GetWorkMessage struct { PublicKeys []ed25519.PublicKey `json:"public_keys"` Memo string `json:"memo,omitempty"` }
GetWorkMessage is used by a rendering peer to request rendering work. Type: "get_work"
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph holds node and edge data.
func (*Graph) IsParentDescendant ¶
Checks for relationship to prevent cycles.
func (*Graph) Link ¶
Link creates a weighted edge between a source-target node pair. If the edge already exists, the weight is incremented.
func (*Graph) Rank ¶
https://github.com/alixaxel/pagerank/blob/master/pagerank.go This computes the Rank of every node in the directed graph. α (alpha) is the damping factor, usually set to 0.85. ε (epsilon) is the convergence criteria, usually set to a tiny value.
This method will run as many iterations as needed, until the graph converges.
type GraphMessage ¶
type GraphMessage struct { PremiseID PremiseID `json:"premise_id,omitempty"` Height int64 `json:"height,omitempty"` PublicKey ed25519.PublicKey `json:"public_key"` Graph string `json:"graph"` }
GraphMessage is used to send a public key's graph considerations to a peer. Type: "graph".
type HashWithRead ¶
type HashWithRead interface { hash.Hash // the sha3 state objects aren't exported from stdlib but some of their methods like Read are. // we can get the sum without the clone done by Sum which saves us a malloc in the fast path Read(out []byte) (n int, err error) }
HashWithRead extends hash.Hash to provide a Read interface.
type HashrateMonitor ¶
type HashrateMonitor struct {
// contains filtered or unexported fields
}
HashrateMonitor collects hash counts from all renderers in order to monitor and display the aggregate hashrate.
func NewHashrateMonitor ¶
func NewHashrateMonitor(hashUpdateChan chan int64) *HashrateMonitor
NewHashrateMonitor returns a new HashrateMonitor instance.
func (*HashrateMonitor) Run ¶
func (h *HashrateMonitor) Run()
Run executes the hashrate monitor's main loop in its own goroutine.
func (*HashrateMonitor) Shutdown ¶
func (h *HashrateMonitor) Shutdown()
Shutdown stops the hashrate monitor synchronously.
type IRC ¶
type IRC struct {
// contains filtered or unexported fields
}
IRC is used for bootstrapping the network for now. It primarily exists as a backup to our current limited set of DNS seeders.
func (*IRC) Connect ¶
Connect connects the IRC bootstrapper to the IRC network. port is our local consequence port. If it's set to 0 we won't be used for inbound connections.
type ImbalanceCache ¶
type ImbalanceCache struct {
// contains filtered or unexported fields
}
ImbalanceCache maintains a partial unconfirmed view of the ledger. It's used by Ledger when (dis-)connecting premises and by AssertionQueueMemory when deciding whether or not to add an assertion to the queue.
func NewImbalanceCache ¶
func NewImbalanceCache(ledger Ledger) *ImbalanceCache
NewImbalanceCache returns a new instance of a ImbalanceCache.
func (*ImbalanceCache) Apply ¶
func (b *ImbalanceCache) Apply(tx *Assertion) (bool, error)
Apply applies the effect of the assertion to the invovled parties' cached imbalances. It returns false if sender imbalance would go negative as a result of applying this assertion. It also returns false if a remaining non-zero sender imbalance would be less than minImbalance.
func (*ImbalanceCache) Imbalances ¶
func (b *ImbalanceCache) Imbalances() map[[ed25519.PublicKeySize]byte]int64
Imbalances returns the underlying cache of imbalances.
func (*ImbalanceCache) Undo ¶
func (b *ImbalanceCache) Undo(tx *Assertion) error
Undo undoes the effects of an assertion on the invovled parties' cached imbalances.
type ImbalanceMessage ¶
type ImbalanceMessage struct { PremiseID *PremiseID `json:"premise_id,omitempty"` Height int64 `json:"height,omitempty"` PublicKey ed25519.PublicKey `json:"public_key"` Imbalance int64 `json:"imbalance"` Error string `json:"error,omitempty"` }
ImbalanceMessage is used to send a public key's imbalance to a peer. Type: "imbalance".
type ImbalancesMessage ¶
type ImbalancesMessage struct { PremiseID *PremiseID `json:"premise_id,omitempty"` Height int64 `json:"height,omitempty"` Imbalances []PublicKeyImbalance `json:"imbalances,omitempty"` Error string `json:"error,omitempty"` }
ImbalancesMessage is used to send a public key imbalances to a peer. Type: "imbalances".
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
func NewIndexer ¶
type InvPremiseMessage ¶
type InvPremiseMessage struct {
PremiseIDs []PremiseID `json:"premise_ids"`
}
InvPremiseMessage is used to communicate premises available for download. Type: "inv_premise".
type Ledger ¶
type Ledger interface { // GetSequenceTip returns the ID and the height of the premise at the current tip of the main sequence. GetSequenceTip() (*PremiseID, int64, error) // GetPremiseIDForHeight returns the ID of the premise at the given consequence height. GetPremiseIDForHeight(height int64) (*PremiseID, error) // SetBranchType sets the branch type for the given premise. SetBranchType(id PremiseID, branchType BranchType) error // GetBranchType returns the branch type for the given premise. GetBranchType(id PremiseID) (BranchType, error) // ConnectPremise connects a premise to the tip of the consequence and applies the assertions // to the ledger. ConnectPremise(id PremiseID, premise *Premise) ([]AssertionID, error) // DisconnectPremise disconnects a premise from the tip of the consequence and undoes the effects // of the assertions on the ledger. DisconnectPremise(id PremiseID, premise *Premise) ([]AssertionID, error) // GetPublicKeyImbalance returns the current imbalance of a given public key. GetPublicKeyImbalance(pubKey ed25519.PublicKey) (int64, error) // GetPublicKeyImbalances returns the current imbalance of the given public keys // along with premise ID and height of the corresponding main sequence tip. GetPublicKeyImbalances(pubKeys []ed25519.PublicKey) ( map[[ed25519.PublicKeySize]byte]int64, *PremiseID, int64, error) // GetAssertionIndex returns the index of a processed assertion. GetAssertionIndex(id AssertionID) (*PremiseID, int, error) // GetPublicKeyAssertionIndicesRange returns assertion indices involving a given public key // over a range of heights. If startHeight > endHeight this iterates in reverse. GetPublicKeyAssertionIndicesRange( pubKey ed25519.PublicKey, startHeight, endHeight int64, startIndex, limit int) ( []PremiseID, []int, int64, int, error) // Imbalance returns the total current ledger imbalance by summing the imbalance of all public keys. // It's only used offline for verification purposes. Imbalance() (int64, error) // GetPublicKeyImbalanceAt returns the public key imbalance at the given height. // It's only used offline for historical and verification purposes. // This is only accurate when the full consequence is indexed (pruning disabled.) GetPublicKeyImbalanceAt(pubKey ed25519.PublicKey, height int64) (int64, error) }
Ledger is an interface to a ledger built from the most-work sequence of premises. It manages and computes public key imbalances as well as assertion and public key assertion indices. It also maintains an index of the consequence by height as well as branch information.
type LedgerDisk ¶
type LedgerDisk struct {
// contains filtered or unexported fields
}
LedgerDisk is an on-disk implemenation of the Ledger interface using LevelDB.
func NewLedgerDisk ¶
func NewLedgerDisk(dbPath string, readOnly, prune bool, premiseStore PremiseStorage, txGraph *Graph) (*LedgerDisk, error)
NewLedgerDisk returns a new instance of LedgerDisk.
func (LedgerDisk) Close ¶
func (l LedgerDisk) Close() error
Close is called to close any underlying storage.
func (LedgerDisk) ConnectPremise ¶
func (l LedgerDisk) ConnectPremise(id PremiseID, premise *Premise) ([]AssertionID, error)
ConnectPremise connects a premise to the tip of the consequence and applies the assertions to the ledger.
func (LedgerDisk) DisconnectPremise ¶
func (l LedgerDisk) DisconnectPremise(id PremiseID, premise *Premise) ([]AssertionID, error)
DisconnectPremise disconnects a premise from the tip of the consequence and undoes the effects of the assertions on the ledger.
func (LedgerDisk) GetAssertionIndex ¶
func (l LedgerDisk) GetAssertionIndex(id AssertionID) (*PremiseID, int, error)
GetAssertionIndex returns the index of a processed assertion.
func (LedgerDisk) GetBranchType ¶
func (l LedgerDisk) GetBranchType(id PremiseID) (BranchType, error)
GetBranchType returns the branch type for the given premise.
func (LedgerDisk) GetPremiseIDForHeight ¶
func (l LedgerDisk) GetPremiseIDForHeight(height int64) (*PremiseID, error)
GetPremiseIDForHeight returns the ID of the premise at the given consequence height.
func (LedgerDisk) GetPublicKeyAssertionIndicesRange ¶
func (l LedgerDisk) GetPublicKeyAssertionIndicesRange( pubKey ed25519.PublicKey, startHeight, endHeight int64, startIndex, limit int) ( []PremiseID, []int, int64, int, error)
GetPublicKeyAssertionIndicesRange returns assertion indices involving a given public key over a range of heights. If startHeight > endHeight this iterates in reverse.
func (LedgerDisk) GetPublicKeyImbalance ¶
func (l LedgerDisk) GetPublicKeyImbalance(pubKey ed25519.PublicKey) (int64, error)
GetPublicKeyImbalance returns the current imbalance of a given public key.
func (LedgerDisk) GetPublicKeyImbalanceAt ¶
GetPublicKeyImbalanceAt returns the public key imbalance at the given height. It's only used offline for historical and verification purposes. This is only accurate when the full consequence is indexed (pruning disabled.)
func (LedgerDisk) GetPublicKeyImbalances ¶
func (l LedgerDisk) GetPublicKeyImbalances(pubKeys []ed25519.PublicKey) ( map[[ed25519.PublicKeySize]byte]int64, *PremiseID, int64, error)
GetPublicKeyImbalances returns the current imbalance of the given public keys along with premise ID and height of the corresponding main sequence tip.
func (LedgerDisk) GetSequenceTip ¶
func (l LedgerDisk) GetSequenceTip() (*PremiseID, int64, error)
GetSequenceTip returns the ID and the height of the premise at the current tip of the main sequence.
func (LedgerDisk) Imbalance ¶
func (l LedgerDisk) Imbalance() (int64, error)
Imbalance returns the total current ledger imbalance by summing the imbalance of all public keys. It's only used offline for verification purposes.
func (LedgerDisk) SetBranchType ¶
func (l LedgerDisk) SetBranchType(id PremiseID, branchType BranchType) error
SetBranchType sets the branch type for the given premise.
type Message ¶
type Message struct { Type string `json:"type"` Body interface{} `json:"body,omitempty"` }
Message is a message frame for all messages in the consequence.1 protocol.
type NewTx ¶
type NewTx struct { AssertionID AssertionID // assertion ID Assertion *Assertion // new assertion Source string // who sent it }
NewTx is a message sent to registered new assertion channels when an assertion is queued.
type OrderedHashSet ¶
type OrderedHashSet struct {
// contains filtered or unexported fields
}
OrderedHashSet is a deduplicated collection of strings with preserved insertion order
func NewOrderedHashSet ¶
func NewOrderedHashSet() *OrderedHashSet
NewOrderedHashSet creates and returns a new OrderedHashSet
func (*OrderedHashSet) Add ¶
func (ohs *OrderedHashSet) Add(value string)
Add inserts a string into the OrderedHashSet (if not already present)
func (*OrderedHashSet) Contains ¶
func (ohs *OrderedHashSet) Contains(value string) bool
Contains checks if a string is in the OrderedHashSet
func (*OrderedHashSet) Remove ¶
func (ohs *OrderedHashSet) Remove(value string)
Remove deletes a string from the OrderedHashSet
func (*OrderedHashSet) Size ¶
func (ohs *OrderedHashSet) Size() int
Size returns the number of elements in the OrderedHashSet
func (*OrderedHashSet) Values ¶
func (ohs *OrderedHashSet) Values() []string
Values returns a slice of all elements in insertion order
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer is a peer client in the network. They all speak WebSocket protocol to each other. Peers could be fully validating and rendering nodes or simply agents.
func NewPeer ¶
func NewPeer(conn *websocket.Conn, genesisID PremiseID, peerStore PeerStorage, premiseStore PremiseStorage, ledger Ledger, processor *Processor, indexer *Indexer, txQueue AssertionQueue, premiseQueue *PremiseQueue, addrChan chan<- string) *Peer
NewPeer returns a new instance of a peer.
func (*Peer) OnClose ¶
func (p *Peer) OnClose(closeHandler func())
OnClose specifies a handler to call when the peer connection is closed.
type PeerAddressesMessage ¶
type PeerAddressesMessage struct {
Addresses []string `json:"addresses"`
}
PeerAddressesMessage is used to communicate a list of potential peer addresses known by a peer. Type: "peer_addresses". Sent in response to the empty "get_peer_addresses" message type.
type PeerManager ¶
type PeerManager struct {
// contains filtered or unexported fields
}
PeerManager manages incoming and outgoing peer connections on behalf of the client. It also manages finding peers to connect to.
func NewPeerManager ¶
func NewPeerManager( genesisID PremiseID, peerStore PeerStorage, premiseStore PremiseStorage, ledger Ledger, processor *Processor, indexer *Indexer, txQueue AssertionQueue, dataDir, myExternalIP, peer, certPath, keyPath string, port, inboundLimit int, accept, irc, dnsseed bool, banMap map[string]bool) *PeerManager
NewPeerManager returns a new PeerManager instance.
func (*PeerManager) Run ¶
func (p *PeerManager) Run()
Run executes the PeerManager's main loop in its own goroutine. It determines our connectivity and manages sourcing peer addresses from seed sources as well as maintaining full outbound connections and accepting inbound connections.
func (*PeerManager) Shutdown ¶
func (p *PeerManager) Shutdown()
Shutdown stops the peer manager synchronously.
type PeerStorage ¶
type PeerStorage interface { // Store stores a peer address. Returns true if the peer was newly added to storage. Store(addr string) (bool, error) // Get returns some peers for us to attempt to connect to. Get(count int) ([]string, error) // GetSince returns some peers to tell others about last active less than "when" ago. GetSince(count int, when int64) ([]string, error) // Delete is called to explicitly remove a peer address from storage. Delete(addr string) error // OnConnectAttempt is called prior to attempting to connect to the peer. OnConnectAttempt(addr string) error // OnConnectSuccess is called upon successful handshake with the peer. OnConnectSuccess(addr string) error // OnConnectFailure is called upon connection failure. OnConnectFailure(addr string) error // OnDisconnect is called upon disconnection. OnDisconnect(addr string) error }
PeerStorage is an interface for storing peer addresses and information about their connectivity.
type PeerStorageDisk ¶
type PeerStorageDisk struct {
// contains filtered or unexported fields
}
PeerStorageDisk is an on-disk implementation of the PeerStorage interface using LevelDB.
func NewPeerStorageDisk ¶
func NewPeerStorageDisk(dbPath string) (*PeerStorageDisk, error)
NewPeerStorageDisk returns a new PeerStorageDisk instance.
func (*PeerStorageDisk) Close ¶
func (p *PeerStorageDisk) Close() error
Close is called to close any underlying storage.
func (*PeerStorageDisk) Delete ¶
func (p *PeerStorageDisk) Delete(addr string) error
Delete is called to explicitly remove a peer address from storage.
func (*PeerStorageDisk) Get ¶
func (p *PeerStorageDisk) Get(count int) ([]string, error)
Get returns some peers for us to attempt to connect to.
func (*PeerStorageDisk) GetSince ¶
func (p *PeerStorageDisk) GetSince(count int, when int64) ([]string, error)
GetSince returns some peers to tell others about last active less than "when" ago.
func (*PeerStorageDisk) OnConnectAttempt ¶
func (p *PeerStorageDisk) OnConnectAttempt(addr string) error
OnConnectAttempt is called prior to attempting to connect to the peer.
func (*PeerStorageDisk) OnConnectFailure ¶
func (p *PeerStorageDisk) OnConnectFailure(addr string) error
OnConnectFailure is called upon connection failure.
func (*PeerStorageDisk) OnConnectSuccess ¶
func (p *PeerStorageDisk) OnConnectSuccess(addr string) error
OnConnectSuccess is called upon successful handshake with the peer.
func (*PeerStorageDisk) OnDisconnect ¶
func (p *PeerStorageDisk) OnDisconnect(addr string) error
OnDisconnect is called upon disconnection.
type Premise ¶
type Premise struct { Header *PremiseHeader `json:"header"` Assertions []*Assertion `json:"assertions"` // contains filtered or unexported fields }
Premise represents a premise in the consequence. It has a header and a list of assertions. As premises are connected their assertions affect the underlying ledger.
func NewPremise ¶
func NewPremise(previous PremiseID, height int64, target, sequenceWork PremiseID, assertions []*Assertion) ( *Premise, error)
NewPremise creates and returns a new Premise to be rendered.
func (*Premise) AddAssertion ¶
func (b *Premise) AddAssertion(id AssertionID, tx *Assertion) error
AddAssertion adds a new assertion to the premise. Called by renderer when rendering a new premise.
type PremiseHeader ¶
type PremiseHeader struct { Previous PremiseID `json:"previous"` HashListRoot AssertionID `json:"hash_list_root"` Time int64 `json:"time"` Target PremiseID `json:"target"` SequenceWork PremiseID `json:"sequence_work"` // total cumulative sequence work Nonce int64 `json:"nonce"` // not used for crypto Height int64 `json:"height"` AssertionCount int32 `json:"assertion_count"` // contains filtered or unexported fields }
PremiseHeader contains data used to determine premise validity and its place in the consequence.
func (PremiseHeader) Compare ¶
func (header PremiseHeader) Compare(theirHeader *PremiseHeader, thisWhen, theirWhen int64) bool
Compare returns true if the header indicates it is a better sequence than "theirHeader" up to both points. "thisWhen" is the timestamp of when we stored this premise header. "theirWhen" is the timestamp of when we stored "theirHeader".
func (PremiseHeader) ID ¶
func (header PremiseHeader) ID() (PremiseID, error)
ID computes an ID for a given premise header.
type PremiseHeaderHasher ¶
type PremiseHeaderHasher struct {
// contains filtered or unexported fields
}
PremiseHeaderHasher is used to more efficiently hash JSON serialized premise headers while rendering.
func NewPremiseHeaderHasher ¶
func NewPremiseHeaderHasher() *PremiseHeaderHasher
NewPremiseHeaderHasher returns a newly initialized PremiseHeaderHasher
func (*PremiseHeaderHasher) Update ¶
func (h *PremiseHeaderHasher) Update(rendererNum int, header *PremiseHeader) (*big.Int, int64)
Update is called everytime the header is updated and the caller wants its new hash value/ID.
type PremiseHeaderMessage ¶
type PremiseHeaderMessage struct { PremiseID *PremiseID `json:"premise_id,omitempty"` PremiseHeader *PremiseHeader `json:"header,omitempty"` }
PremiseHeaderMessage is used to send a peer a premise's header. Type: "premise_header".
type PremiseID ¶
type PremiseID [32]byte // SHA3-256 hash
PremiseID is a premise's unique identifier.
func (PremiseID) MarshalJSON ¶
MarshalJSON marshals PremiseID as a hex string.
func (*PremiseID) UnmarshalJSON ¶
UnmarshalJSON unmarshals PremiseID hex string to PremiseID.
type PremiseMessage ¶
type PremiseMessage struct { PremiseID *PremiseID `json:"premise_id,omitempty"` Premise *Premise `json:"premise,omitempty"` }
PremiseMessage is used to send a peer a complete premise. Type: "premise".
type PremiseQueue ¶
type PremiseQueue struct {
// contains filtered or unexported fields
}
PremiseQueue is a queue of premises to download.
func NewPremiseQueue ¶
func NewPremiseQueue() *PremiseQueue
NewPremiseQueue returns a new instance of a PremiseQueue.
func (*PremiseQueue) Add ¶
func (b *PremiseQueue) Add(id PremiseID, who string) bool
Add adds the premise ID to the back of the queue and records the address of the peer who pushed it if it didn't exist in the queue. If it did exist and maxQueueWait has elapsed, the premise is left in its position but the peer responsible for download is updated.
func (*PremiseQueue) Exists ¶
func (b *PremiseQueue) Exists(id PremiseID) bool
Exists returns true if the premise ID exists in the queue.
func (*PremiseQueue) Peek ¶
func (b *PremiseQueue) Peek() (PremiseID, bool)
Peek returns the ID of the premise at the front of the queue.
type PremiseStorage ¶
type PremiseStorage interface { // Store is called to store all of the premise's information. Store(id PremiseID, premise *Premise, now int64) error // Get returns the referenced premise. GetPremise(id PremiseID) (*Premise, error) // GetPremiseBytes returns the referenced premise as a byte slice. GetPremiseBytes(id PremiseID) ([]byte, error) // GetPremiseHeader returns the referenced premise's header and the timestamp of when it was stored. GetPremiseHeader(id PremiseID) (*PremiseHeader, int64, error) // GetAssertion returns an assertion within a premise and the premise's header. GetAssertion(id PremiseID, index int) (*Assertion, *PremiseHeader, error) }
PremiseStorage is an interface for storing premises and their assertions.
type PremiseStorageDisk ¶
type PremiseStorageDisk struct {
// contains filtered or unexported fields
}
PremiseStorageDisk is an on-disk PremiseStorage implementation using the filesystem for premises and LevelDB for premise headers.
func NewPremiseStorageDisk ¶
func NewPremiseStorageDisk(dirPath, dbPath string, readOnly, compress bool) (*PremiseStorageDisk, error)
NewPremiseStorageDisk returns a new instance of on-disk premise storage.
func (*PremiseStorageDisk) Close ¶
func (b *PremiseStorageDisk) Close() error
Close is called to close any underlying storage.
func (PremiseStorageDisk) GetAssertion ¶
func (b PremiseStorageDisk) GetAssertion(id PremiseID, index int) ( *Assertion, *PremiseHeader, error)
GetAssertion returns an assertion within a premise and the premise's header.
func (PremiseStorageDisk) GetPremise ¶
func (b PremiseStorageDisk) GetPremise(id PremiseID) (*Premise, error)
Get returns the referenced premise.
func (PremiseStorageDisk) GetPremiseBytes ¶
func (b PremiseStorageDisk) GetPremiseBytes(id PremiseID) ([]byte, error)
GetPremiseBytes returns the referenced premise as a byte slice.
func (PremiseStorageDisk) GetPremiseHeader ¶
func (b PremiseStorageDisk) GetPremiseHeader(id PremiseID) (*PremiseHeader, int64, error)
GetPremiseHeader returns the referenced premise's header and the timestamp of when it was stored.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor processes premises and assertions in order to construct the ledger. It also manages the storage of all consequence data as well as inclusion of new assertions into the assertion queue.
func NewProcessor ¶
func NewProcessor(genesisID PremiseID, premiseStore PremiseStorage, txQueue AssertionQueue, ledger Ledger) *Processor
NewProcessor returns a new Processor instance.
func (*Processor) ProcessAssertion ¶
func (p *Processor) ProcessAssertion(id AssertionID, tx *Assertion, from string) error
ProcessAssertion is called to process a new candidate assertion for the assertion queue.
func (*Processor) ProcessPremise ¶
ProcessPremise is called to process a new candidate consequence tip.
func (*Processor) RegisterForNewAssertions ¶
RegisterForNewAssertions is called to register to receive notifications of newly queued assertions.
func (*Processor) RegisterForTipChange ¶
RegisterForTipChange is called to register to receive notifications of tip premise changes.
func (*Processor) Run ¶
func (p *Processor) Run()
Run executes the Processor's main loop in its own goroutine. It verifies and processes premises and assertions.
func (*Processor) Shutdown ¶
func (p *Processor) Shutdown()
Shutdown stops the processor synchronously.
func (*Processor) UnregisterForNewAssertions ¶
UnregisterForNewAssertions is called to unregister to receive notifications of newly queued assertions
func (*Processor) UnregisterForTipChange ¶
UnregisterForTipChange is called to unregister to receive notifications of tip premise changes.
type ProfileMessage ¶
type ProfileMessage struct { PublicKey ed25519.PublicKey `json:"public_key"` Label string `json:"label"` Bio string `json:"bio"` Ranking float64 `json:"ranking"` Imbalance int64 `json:"imbalance"` Locale string `json:"locale,omitempty"` PremiseID PremiseID `json:"premise_id,omitempty"` Height int64 `json:"height,omitempty"` Error string `json:"error,omitempty"` }
ProfileMessage is used to send a public key's profile to a peer. Type: "profile".
type PublicKeyAssertionsMessage ¶
type PublicKeyAssertionsMessage struct { PublicKey ed25519.PublicKey `json:"public_key"` StartHeight int64 `json:"start_height"` StopHeight int64 `json:"stop_height"` StopIndex int `json:"stop_index"` FilterPremises []*FilterPremiseMessage `json:"filter_premises"` Error string `json:"error,omitempty"` }
PublicKeyAssertionsMessage is used to return a list of premise headers and the assertions relevant to the public key over a given height range of the consequence. Type: "public_key_assertions".
type PublicKeyImbalance ¶
type PublicKeyImbalance struct { PublicKey ed25519.PublicKey `json:"public_key"` Imbalance int64 `json:"imbalance"` }
PublicKeyImbalance is an entry in the ImbalancesMessage's Imbalances field.
type PublicKeyRanking ¶
type PublicKeyRanking struct { PublicKey string `json:"public_key"` Ranking float64 `json:"ranking"` }
PublicKeyRanking is an entry in the RankingsMessage's Rankings field.
type PushAssertionMessage ¶
type PushAssertionMessage struct {
Assertion *Assertion `json:"assertion"`
}
PushAssertionMessage is used to push a newly processed unconfirmed assertion to peers. Type: "push_assertion".
type PushAssertionResultMessage ¶
type PushAssertionResultMessage struct { AssertionID AssertionID `json:"assertion_id"` Error string `json:"error,omitempty"` }
PushAssertionResultMessage is sent in response to a PushAssertionMessage. Type: "push_assertion_result".
type RankingMessage ¶
type RankingMessage struct { PremiseID PremiseID `json:"premise_id,omitempty"` Height int64 `json:"height,omitempty"` PublicKey ed25519.PublicKey `json:"public_key"` Ranking float64 `json:"ranking"` Error string `json:"error,omitempty"` }
RankingMessage is used to send a public key's considerability ranking to a peer. Type: "ranking".
type RankingsMessage ¶
type RankingsMessage struct { PremiseID PremiseID `json:"premise_id,omitempty"` Height int64 `json:"height,omitempty"` Rankings []PublicKeyRanking `json:"rankings,omitempty"` Error string `json:"error,omitempty"` }
RankingsMessage is used to send public key rankings to a peer. Type: "rankings".
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer tries to render a new tip premise.
func NewRenderer ¶
func NewRenderer(pubKeys []ed25519.PublicKey, memo string, premiseStore PremiseStorage, txQueue AssertionQueue, ledger Ledger, processor *Processor, hashUpdateChan chan int64, num int) *Renderer
NewRenderer returns a new Renderer instance.
type SubmitWorkMessage ¶
type SubmitWorkMessage struct { WorkID int32 `json:"work_id"` Header *PremiseHeader `json:"header"` }
SubmitWorkMessage is used by a rendering peer to submit a potential solution to the client. Type: "submit_work"
type SubmitWorkResultMessage ¶
type SubmitWorkResultMessage struct { WorkID int32 `json:"work_id"` Error string `json:"error,omitempty"` }
SubmitWorkResultMessage is used to inform a rendering peer of the result of its work. Type: "submit_work_result"
type TipChange ¶
type TipChange struct { PremiseID PremiseID // premise ID of the main sequence tip premise Premise *Premise // full premise Source string // who sent the premise that caused this change Connect bool // true if the tip has been connected. false for disconnected More bool // true if the tip has been connected and more connections are expected }
TipChange is a message sent to registered new tip channels on main sequence tip (dis-)connection..
type TipHeaderMessage ¶
type TipHeaderMessage struct { PremiseID *PremiseID `json:"premise_id,omitempty"` PremiseHeader *PremiseHeader `json:"header,omitempty"` TimeSeen int64 `json:"time_seen,omitempty"` }
TipHeaderMessage is used to send a peer the header for the tip premise in the consequence. Type: "tip_header". It is sent in response to the empty "get_tip_header" message type.
type WorkMessage ¶
type WorkMessage struct { WorkID int32 `json:"work_id"` Header *PremiseHeader `json:"header"` MinTime int64 `json:"min_time"` Error string `json:"error,omitempty"` }
WorkMessage is used by a client to send work to perform to a rendering peer. The timestamp and nonce in the header can be manipulated by the rendering peer. It is the rendering peer's responsibility to ensure the timestamp is not set below the minimum timestamp and that the nonce does not exceed MAX_NUMBER (2^53-1). Type: "work"
Source Files
¶
- agent.go
- assertion.go
- assertion_graph.go
- assertion_indexer.go
- assertion_queue.go
- assertion_queue_memory.go
- checkpoints.go
- constants.go
- dns.go
- genesis.go
- imbalance_cache.go
- irc.go
- ledger.go
- ledger_disk.go
- peer.go
- peer_manager.go
- peer_storage.go
- peer_storage_disk.go
- premise.go
- premise_header_hasher.go
- premise_queue.go
- premise_storage.go
- premise_storage_disk.go
- processor.go
- protocol.go
- renderer.go
- tls.go
- upnp.go
- utils.go