Skip to main content

ClientConnection

Struct ClientConnection 

Source
pub struct ClientConnection { /* private fields */ }
Expand description

ノードへ問い合わせる側の接続。要求を1つ送って、応答を1つ受け取る。

Implementations§

Source§

impl ClientConnection

Source

pub fn connect( address: &str, identity: &Identity, timeout: Duration, ) -> Result<Self, ConnectError>

address に接続する。相手のチェーンは catapult と同じ条件で確かめる。

Source

pub fn peer_certificates(&self) -> Vec<Vec<u8>>

相手が出した証明書の DER。ノード、CA の順のはず。

Source

pub fn is_heika(&self) -> bool

相手も heika で、heika だけのパケットを使えるか(heika-tls の ALPN)

Source

pub fn peer_capabilities(&self) -> Option<&[String]>

相手から届いた capability。相手が heika でないか、まだ届いていなければ None。 相手の capability は、つないだあと最初の応答より先に届く

Source

pub fn chain_statistics(&mut self) -> Result<ChainStatistics, QueryError>

チェーンの高さ、確定した高さ、スコア。

Source

pub fn info(&mut self) -> Result<NetworkNode, QueryError>

ノード自身の情報。

Source

pub fn network_time(&mut self) -> Result<NetworkTime, QueryError>

ノードのネットワーク時刻。catapult は自分の時計をピアに合わせてずらしているので、OS の時計とは違うことがある。 自分の時計との差は、要求を送った時刻と応答を受け取った時刻を測って NetworkTime::offset で出す

Source

pub fn peers(&mut self) -> Result<Vec<NetworkNode>, QueryError>

ノードが知っているほかのノード。

Source

pub fn pull_blocks( &mut self, height: u64, num_blocks: u32, num_response_bytes: u32, ) -> Result<Vec<Vec<u8>>, QueryError>

height から最大 num_blocks 件、合計 num_response_bytes バイトまでのブロックを取る。

ノードは設定の maxBlocksPerSyncAttempt と maxChainBytesPerSyncAttempt で切り詰め、 バイト数の上限を超えても最低1件は返す。高さがチェーンより先なら空になる。 ブロックの中身は確かめず、1件ずつに切り出すだけにする。

Source

pub fn pull_block_hashes( &mut self, height: u64, num_hashes: u32, ) -> Result<Vec<[u8; 32]>, QueryError>

height から最大 num_hashes 件のブロックのハッシュを、高さの順に取る。

ノードは設定の maxHashesPerSyncAttempt と持っているブロックの数で切り詰める。高さがチェーンより先なら空になる。 分かれ目を探すのに使う(catapult の CompareChains)。

Source

pub fn pull_transactions( &mut self, min_deadline: u64, min_fee_multiplier: u32, known_short_hashes: &[u32], ) -> Result<Vec<Vec<u8>>, QueryError>

ノードの未承認のトランザクションのうち、期限が min_deadline 以降で、最大手数料がサイズに min_fee_multiplier を掛けた額以上のものを取る。known_short_hashes(heika_packet::short_hash)にあるものは返ってこない。

ノードは返すバイト数を設定の上限で切るので、未承認のトランザクションが多いと全部は返ってこない。 トランザクションの中身は確かめず、1件ずつに切り出すだけにする。

Source

pub fn finalization_statistics( &mut self, ) -> Result<FinalizedBlockHeader, QueryError>

ノードが最後にファイナライズしたラウンド、高さ、ハッシュ。

Source

pub fn pull_finalization_messages( &mut self, min: FinalizationRound, max: FinalizationRound, known: &[u32], ) -> Result<Vec<Vec<u8>>, QueryError>

ラウンド min から max までの、ノードが集めている投票のメッセージのうち、短いハッシュが known にないものの バイト列(catapult の FinalizationMessage)。中身は確かめない。確定の前に配り合うもので、確定が止まっている ときに、誰がどこまで投票しているかが分かる。投票しないノードは集めていないので、何も返さない

Source

pub fn finalization_proof_at_epoch( &mut self, epoch: u32, ) -> Result<Option<Vec<u8>>, QueryError>

エポック epoch のファイナライズの証明のバイト列(catapult の FinalizationProof)。 ノードが持っていなければ None。中身は確かめない。

Source

pub fn pull_partial_infos( &mut self, min_deadline: u64, known: &[ShortHashPair], ) -> Result<Vec<PulledPartial>, QueryError>

種類 packet_type で本体が body のパケットを押し付ける。catapult は押し付けに答えないので、待たない 連署を待つアグリゲートボンデッドのうち、期限が min_deadline 以降で、known と同じでないものを取る。 知らないものはトランザクションと連署が、知っているものはハッシュと連署が来る(PulledPartial)。 中身は確かめない

Source

pub fn push(&mut self, packet_type: u32, body: &[u8]) -> Result<(), QueryError>

Source

pub fn source_zip(&mut self) -> Result<Option<Vec<u8>>, QueryError>

相手のソースの ZIP。AGPL-3.0 の 13 条のため、heika は REST を立てていなくても P2P で渡せる。 相手が heika でないか、source/zip を名乗っていなければ None

Trait Implementations§

Source§

impl Debug for ClientConnection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.