protocol

package
v0.0.0-...-68fb9df Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_protocol_astris_proto protoreflect.FileDescriptor

Functions

func RegisterAstrisV1Server

func RegisterAstrisV1Server(s grpc.ServiceRegistrar, srv AstrisV1Server)

Types

type Acceptance

type Acceptance struct {
	Accepted bool `protobuf:"varint,1,opt,name=accepted,proto3" json:"accepted,omitempty"`
	// contains filtered or unexported fields
}

func (*Acceptance) Descriptor deprecated

func (*Acceptance) Descriptor() ([]byte, []int)

Deprecated: Use Acceptance.ProtoReflect.Descriptor instead.

func (*Acceptance) GetAccepted

func (x *Acceptance) GetAccepted() bool

func (*Acceptance) ProtoMessage

func (*Acceptance) ProtoMessage()

func (*Acceptance) ProtoReflect

func (x *Acceptance) ProtoReflect() protoreflect.Message

func (*Acceptance) Reset

func (x *Acceptance) Reset()

func (*Acceptance) String

func (x *Acceptance) String() string

type AstrisV1Client

type AstrisV1Client interface {
	// this is for announcing and managing peers.
	PeerExchange(ctx context.Context, in *Peer, opts ...grpc.CallOption) (AstrisV1_PeerExchangeClient, error)
	// this is the connection we open to receive blocks
	// we only have a receive function. If other peers
	// want blocks from us, they must call RecieveBlocks
	// to open the channel
	// the client should immediately send it's current "HEAD"
	// block header, from which the client can decide whether
	// to ask for more blocks, or ignore this peer
	RecvBlocks(ctx context.Context, in *Empty, opts ...grpc.CallOption) (AstrisV1_RecvBlocksClient, error)
	// recieve a specific block from the peer, if they have it
	// this can be used to populate your chain
	// addressed.
	GetBlock(ctx context.Context, in *BlockID, opts ...grpc.CallOption) (*FullBlock, error)
	// this can be used to fetch a stream of blocks starting at the given one
	// if the peer doesn't recognise the starting block, it should bail.
	// if the client doesn't recieve a valid ordered sequence of blocks,
	// it should bail. This is used to "fast-forward" a client.
	FromBlock(ctx context.Context, in *BlockID, opts ...grpc.CallOption) (AstrisV1_FromBlockClient, error)
	// This method is used to find the largest depth common block
	// between two divergent chains
	AtDepth(ctx context.Context, in *Depth, opts ...grpc.CallOption) (*BlockID, error)
	// Publish a block onto the chain, to allow us to "push" blocks to a node we have connected to
	// If they have connected to us, we can just use their RecvBlocks to deliver. This is designed
	// for the clients that wish to connect and publish rather than participate in the full mesh
	PublishBlock(ctx context.Context, in *FullBlock, opts ...grpc.CallOption) (*Acceptance, error)
}

AstrisV1Client is the client API for AstrisV1 service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewAstrisV1Client

func NewAstrisV1Client(cc grpc.ClientConnInterface) AstrisV1Client

type AstrisV1Server

type AstrisV1Server interface {
	// this is for announcing and managing peers.
	PeerExchange(*Peer, AstrisV1_PeerExchangeServer) error
	// this is the connection we open to receive blocks
	// we only have a receive function. If other peers
	// want blocks from us, they must call RecieveBlocks
	// to open the channel
	// the client should immediately send it's current "HEAD"
	// block header, from which the client can decide whether
	// to ask for more blocks, or ignore this peer
	RecvBlocks(*Empty, AstrisV1_RecvBlocksServer) error
	// recieve a specific block from the peer, if they have it
	// this can be used to populate your chain
	// addressed.
	GetBlock(context.Context, *BlockID) (*FullBlock, error)
	// this can be used to fetch a stream of blocks starting at the given one
	// if the peer doesn't recognise the starting block, it should bail.
	// if the client doesn't recieve a valid ordered sequence of blocks,
	// it should bail. This is used to "fast-forward" a client.
	FromBlock(*BlockID, AstrisV1_FromBlockServer) error
	// This method is used to find the largest depth common block
	// between two divergent chains
	AtDepth(context.Context, *Depth) (*BlockID, error)
	// Publish a block onto the chain, to allow us to "push" blocks to a node we have connected to
	// If they have connected to us, we can just use their RecvBlocks to deliver. This is designed
	// for the clients that wish to connect and publish rather than participate in the full mesh
	PublishBlock(context.Context, *FullBlock) (*Acceptance, error)
	// contains filtered or unexported methods
}

AstrisV1Server is the server API for AstrisV1 service. All implementations must embed UnimplementedAstrisV1Server for forward compatibility

type AstrisV1_FromBlockClient

type AstrisV1_FromBlockClient interface {
	Recv() (*FullBlock, error)
	grpc.ClientStream
}

type AstrisV1_FromBlockServer

type AstrisV1_FromBlockServer interface {
	Send(*FullBlock) error
	grpc.ServerStream
}

type AstrisV1_PeerExchangeClient

type AstrisV1_PeerExchangeClient interface {
	Recv() (*Peer, error)
	grpc.ClientStream
}

type AstrisV1_PeerExchangeServer

type AstrisV1_PeerExchangeServer interface {
	Send(*Peer) error
	grpc.ServerStream
}

type AstrisV1_RecvBlocksClient

type AstrisV1_RecvBlocksClient interface {
	Recv() (*BlockHeader, error)
	grpc.ClientStream
}

type AstrisV1_RecvBlocksServer

type AstrisV1_RecvBlocksServer interface {
	Send(*BlockHeader) error
	grpc.ServerStream
}

type BlockHeader

type BlockHeader struct {
	PrevId      []byte `protobuf:"bytes,1,opt,name=prev_id,json=prevId,proto3" json:"prev_id,omitempty"`
	PayloadHash []byte `protobuf:"bytes,2,opt,name=payload_hash,json=payloadHash,proto3" json:"payload_hash,omitempty"` // this should match the payload
	Timestamp   uint32 `protobuf:"fixed32,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`                      // unix timestamp of block creation
	Proof       uint32 `protobuf:"fixed32,4,opt,name=proof,proto3" json:"proof,omitempty"`                              // proof of work
	Depth       uint64 `protobuf:"varint,5,opt,name=depth,proto3" json:"depth,omitempty"`                               // block height or chain depth
	Kind        uint32 `protobuf:"varint,6,opt,name=kind,proto3" json:"kind,omitempty"`
	// contains filtered or unexported fields
}

this is the block header for a block you can validate the proof of work with just the header but you must validate the payload_hash to confirm the entire block is valid

func (*BlockHeader) Descriptor deprecated

func (*BlockHeader) Descriptor() ([]byte, []int)

Deprecated: Use BlockHeader.ProtoReflect.Descriptor instead.

func (*BlockHeader) GetDepth

func (x *BlockHeader) GetDepth() uint64

func (*BlockHeader) GetKind

func (x *BlockHeader) GetKind() uint32

func (*BlockHeader) GetPayloadHash

func (x *BlockHeader) GetPayloadHash() []byte

func (*BlockHeader) GetPrevId

func (x *BlockHeader) GetPrevId() []byte

func (*BlockHeader) GetProof

func (x *BlockHeader) GetProof() uint32

func (*BlockHeader) GetTimestamp

func (x *BlockHeader) GetTimestamp() uint32

func (*BlockHeader) ProtoMessage

func (*BlockHeader) ProtoMessage()

func (*BlockHeader) ProtoReflect

func (x *BlockHeader) ProtoReflect() protoreflect.Message

func (*BlockHeader) Reset

func (x *BlockHeader) Reset()

func (*BlockHeader) String

func (x *BlockHeader) String() string

type BlockID

type BlockID struct {

	// our block hashes are SHA256 which means 32bytes or 4x64bit values.
	// using the "bytes" value is rubbish as it can be 2^32 long.
	// there is no fixed length possible. We will have to do the validation
	// outside the protobuf code.
	// fortunately the GRPC code has a MaxMessageSize so we can limit the damage.
	Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

this message refers to the ID of a block (its hash)

func (*BlockID) Descriptor deprecated

func (*BlockID) Descriptor() ([]byte, []int)

Deprecated: Use BlockID.ProtoReflect.Descriptor instead.

func (*BlockID) GetId

func (x *BlockID) GetId() []byte

func (*BlockID) ProtoMessage

func (*BlockID) ProtoMessage()

func (*BlockID) ProtoReflect

func (x *BlockID) ProtoReflect() protoreflect.Message

func (*BlockID) Reset

func (x *BlockID) Reset()

func (*BlockID) String

func (x *BlockID) String() string

type Depth

type Depth struct {
	Depth uint64 `protobuf:"fixed64,1,opt,name=depth,proto3" json:"depth,omitempty"`
	// contains filtered or unexported fields
}

The depth we wish to query

func (*Depth) Descriptor deprecated

func (*Depth) Descriptor() ([]byte, []int)

Deprecated: Use Depth.ProtoReflect.Descriptor instead.

func (*Depth) GetDepth

func (x *Depth) GetDepth() uint64

func (*Depth) ProtoMessage

func (*Depth) ProtoMessage()

func (*Depth) ProtoReflect

func (x *Depth) ProtoReflect() protoreflect.Message

func (*Depth) Reset

func (x *Depth) Reset()

func (*Depth) String

func (x *Depth) String() string

type Empty

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

Empty message has no data

func (*Empty) Descriptor deprecated

func (*Empty) Descriptor() ([]byte, []int)

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect

func (x *Empty) ProtoReflect() protoreflect.Message

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

type FullBlock

type FullBlock struct {
	Header  *BlockHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"`
	Payload []byte       `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

this is the full block that contains all the data

func (*FullBlock) Descriptor deprecated

func (*FullBlock) Descriptor() ([]byte, []int)

Deprecated: Use FullBlock.ProtoReflect.Descriptor instead.

func (*FullBlock) GetHeader

func (x *FullBlock) GetHeader() *BlockHeader

func (*FullBlock) GetPayload

func (x *FullBlock) GetPayload() []byte

func (*FullBlock) ProtoMessage

func (*FullBlock) ProtoMessage()

func (*FullBlock) ProtoReflect

func (x *FullBlock) ProtoReflect() protoreflect.Message

func (*FullBlock) Reset

func (x *FullBlock) Reset()

func (*FullBlock) String

func (x *FullBlock) String() string

type Peer

type Peer struct {
	Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"`
	// contains filtered or unexported fields
}

A connectible peer address

func (*Peer) Descriptor deprecated

func (*Peer) Descriptor() ([]byte, []int)

Deprecated: Use Peer.ProtoReflect.Descriptor instead.

func (*Peer) GetTarget

func (x *Peer) GetTarget() string

func (*Peer) ProtoMessage

func (*Peer) ProtoMessage()

func (*Peer) ProtoReflect

func (x *Peer) ProtoReflect() protoreflect.Message

func (*Peer) Reset

func (x *Peer) Reset()

func (*Peer) String

func (x *Peer) String() string

type Server

type Server struct {
	UnimplementedAstrisV1Server
	// contains filtered or unexported fields
}

Server is the server implementation of the Astris Protocol That is, the thing that other nodes connect to to get data. The Client is what "this" node connects to for data. So, the Server is unconcerned by the peers that are connected to it,

func (*Server) AtDepth

func (s *Server) AtDepth(ctx context.Context, d *Depth) (*BlockID, error)

func (*Server) FromBlock

func (s *Server) FromBlock(b *BlockID, stream AstrisV1_FromBlockServer) error

func (*Server) GetBlock

func (s *Server) GetBlock(ctx context.Context, b *BlockID) (*FullBlock, error)

FetchBlock gets a block directlty by hash

func (*Server) PeerExchange

func (s *Server) PeerExchange(peer *Peer, stream AstrisV1_PeerExchangeServer) error

GetPeers allows us to send all our known peers for this election and annouce ones we discover

func (*Server) PublishBlock

func (s *Server) PublishBlock(ctx context.Context, b *FullBlock) (*Acceptance, error)

func (*Server) RecvBlocks

func (s *Server) RecvBlocks(empty *Empty, stream AstrisV1_RecvBlocksServer) error

RecieveBlocks gives us a channel to announce new blocks we validate

type UnimplementedAstrisV1Server

type UnimplementedAstrisV1Server struct {
}

UnimplementedAstrisV1Server must be embedded to have forward compatible implementations.

func (UnimplementedAstrisV1Server) AtDepth

func (UnimplementedAstrisV1Server) FromBlock

func (UnimplementedAstrisV1Server) GetBlock

func (UnimplementedAstrisV1Server) PeerExchange

func (UnimplementedAstrisV1Server) PublishBlock

func (UnimplementedAstrisV1Server) RecvBlocks

type UnsafeAstrisV1Server

type UnsafeAstrisV1Server interface {
	// contains filtered or unexported methods
}

UnsafeAstrisV1Server may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to AstrisV1Server will result in compilation errors.

Jump to

Keyboard shortcuts

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