@x5e/gink
Version:
an eventually consistent database
57 lines (56 loc) • 2.23 kB
TypeScript
import { BundleInfo, BundleView, Connection } from "./typedefs";
import { HasMap } from "./HasMap";
export declare class AbstractConnection implements Connection {
protected listeners: Array<() => void>;
protected peerHasMap?: HasMap;
private unacked;
private unackedChains;
private hasSentInitialSyncState;
private hasRecvInitialSyncState;
private hasSentGreetingState;
private isReadOnlyState;
private _ready;
private onReady;
constructor();
get ready(): Promise<void>;
protected resetAbstractConnection(): void;
get synced(): boolean;
get connected(): boolean;
get isReadOnly(): boolean;
set isReadOnly(value: boolean);
get hasSentGreeting(): boolean;
get hasSentInitialSync(): boolean;
get hasRecvInitialSync(): boolean;
markHasSentGreeting(): void;
markHasSentInitialSync(): void;
markHasRecvInitialSync(): void;
get hasSentUnackedData(): boolean;
onAck(bundleInfo: BundleInfo): void;
protected notify(): void;
subscribe(callback: () => void): () => void;
send(_: Uint8Array): void;
sendInitialBundlesSent(): void;
close(): void;
setPeerHasMap(hasMap?: HasMap): void;
/**
* The Message proto contains an embedded one-of. Essentially this will wrap
* the bundle bytes payload in a wrapper by prefixing a few bytes to it.
* In theory the "Message" proto could be expanded with some extra meta
* (e.g. send time) in the future.
* Note that the bundle is always passed around as bytes and then
* parsed as needed to avoid losing unknown fields.
* @param bundleBytes: the bytes corresponding to a bundle
* @returns a serialized "Message" proto
*/
private static makeBundleMessage;
/**
* Sends a bundle if we've received a greeting and our internal recordkeeping indicates
* that the peer could use this particular bundle (but ensures that we're not sending
* bundles that would cause gaps in the peer's chain.)
* @param bundleBytes The bundle to be sent.
* @param bundleInfo Meta about the bundle.
*/
sendIfNeeded(bundle: BundleView): void;
onReceivedBundle(bundleInfo: BundleInfo): void;
private sendAck;
}