Skip to content

Latest commit

 

History

History
291 lines (137 loc) · 6.35 KB

peculium_core_peer.md

File metadata and controls

291 lines (137 loc) · 6.35 KB

Module peculium_core_peer

Peer Server. Copyright (c) 2013 Alexander Færøy

Behaviours: gen_server, ranch_protocol.

Authors: Alexander Færøy (ahf@0x90.dk).

Description

This module contains a gen_server for representing a peer in the Bitcoin peer-to-peer network.

We are using a single server to represent both incoming and outgoing peers.

Data Types


peer() = pid()

Function Index

block/8Send block message to the given Peer.
code_change/3
getaddr/1Send getaddr message to the given Peer.
getblocks/3Send getblocks message to the given Peer.
getdata/2Send getdata message to the given Peer.
getheaders/3Send getheaders message to the given Peer.
handle_call/3
handle_cast/2
handle_info/2
init/1
ping/1Send ping message to the given Peer.
start_link/2Start Peer server.
stop/1Stop the given Peer.
terminate/2
verack/1Send verack message to the given Peer.
version/2Send version message to the given Peer.

Function Details

block/8


block(Peer::peer(), Version::uint32_t(), PreviousBlock::hash(), MerkleRoot::hash(), Timestamp::non_neg_integer(), Bits::binary(), Nonce::binary(), Transactions::[transaction()]) -> ok



Send block message to the given Peer.

code_change/3

code_change(OldVersion, State, Extra) -> any()

getaddr/1


getaddr(Peer::peer()) -> ok



Send getaddr message to the given Peer.

getblocks/3


getblocks(Peer::peer(), BlockLocator::block_locator(), BlockStop::hash()) -> ok



Send getblocks message to the given Peer.

getdata/2


getdata(Peer::peer(), Invs::[inv()]) -> ok



Send getdata message to the given Peer.

getheaders/3


getheaders(Peer::peer(), BlockLocator::block_locator(), BlockStop::hash()) -> ok



Send getheaders message to the given Peer.

handle_call/3

handle_call(Request, From, State) -> any()

handle_cast/2

handle_cast(Message, State) -> any()

handle_info/2

handle_info(Info, State) -> any()

init/1


init(Arguments::[term()]) -> {ok, term()} | {ok, term(), non_neg_integer() | infinity} | {ok, term(), hibernate} | {stop, any()} | ignore



ping/1


ping(Peer::peer()) -> ok



Send ping message to the given Peer.

start_link/2


start_link(Address::inet:ip_address(), Port::inet:port_number()) -> {ok, peer()} | ignore | {error, any()}



Start Peer server.

stop/1


stop(Peer::peer()) -> ok



Stop the given Peer.

terminate/2

terminate(Reason, State) -> any()

verack/1


verack(Peer::peer()) -> ok



Send verack message to the given Peer.

version/2


version(Peer::peer(), Nonce::binary()) -> ok



Send version message to the given Peer.