Documentation ¶
Index ¶
- Variables
- func RegisterAstrisV1Server(s grpc.ServiceRegistrar, srv AstrisV1Server)
- type Acceptance
- type AstrisV1Client
- type AstrisV1Server
- type AstrisV1_FromBlockClient
- type AstrisV1_FromBlockServer
- type AstrisV1_PeerExchangeClient
- type AstrisV1_PeerExchangeServer
- type AstrisV1_RecvBlocksClient
- type AstrisV1_RecvBlocksServer
- type BlockHeader
- func (*BlockHeader) Descriptor() ([]byte, []int)deprecated
- func (x *BlockHeader) GetDepth() uint64
- func (x *BlockHeader) GetKind() uint32
- func (x *BlockHeader) GetPayloadHash() []byte
- func (x *BlockHeader) GetPrevId() []byte
- func (x *BlockHeader) GetProof() uint32
- func (x *BlockHeader) GetTimestamp() uint32
- func (*BlockHeader) ProtoMessage()
- func (x *BlockHeader) ProtoReflect() protoreflect.Message
- func (x *BlockHeader) Reset()
- func (x *BlockHeader) String() string
- type BlockID
- type Depth
- type Empty
- type FullBlock
- type Peer
- type Server
- func (s *Server) AtDepth(ctx context.Context, d *Depth) (*BlockID, error)
- func (s *Server) FromBlock(b *BlockID, stream AstrisV1_FromBlockServer) error
- func (s *Server) GetBlock(ctx context.Context, b *BlockID) (*FullBlock, error)
- func (s *Server) PeerExchange(peer *Peer, stream AstrisV1_PeerExchangeServer) error
- func (s *Server) PublishBlock(ctx context.Context, b *FullBlock) (*Acceptance, error)
- func (s *Server) RecvBlocks(empty *Empty, stream AstrisV1_RecvBlocksServer) error
- type UnimplementedAstrisV1Server
- func (UnimplementedAstrisV1Server) AtDepth(context.Context, *Depth) (*BlockID, error)
- func (UnimplementedAstrisV1Server) FromBlock(*BlockID, AstrisV1_FromBlockServer) error
- func (UnimplementedAstrisV1Server) GetBlock(context.Context, *BlockID) (*FullBlock, error)
- func (UnimplementedAstrisV1Server) PeerExchange(*Peer, AstrisV1_PeerExchangeServer) error
- func (UnimplementedAstrisV1Server) PublishBlock(context.Context, *FullBlock) (*Acceptance, error)
- func (UnimplementedAstrisV1Server) RecvBlocks(*Empty, AstrisV1_RecvBlocksServer) error
- type UnsafeAstrisV1Server
Constants ¶
This section is empty.
Variables ¶
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) ProtoMessage ¶
func (*BlockID) ProtoMessage()
func (*BlockID) ProtoReflect ¶
func (x *BlockID) ProtoReflect() protoreflect.Message
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) ProtoMessage ¶
func (*Depth) ProtoMessage()
func (*Depth) ProtoReflect ¶
func (x *Depth) ProtoReflect() protoreflect.Message
type Empty ¶
type Empty struct {
// contains filtered or unexported fields
}
Empty message has no data
func (*Empty) Descriptor
deprecated
func (*Empty) ProtoMessage ¶
func (*Empty) ProtoMessage()
func (*Empty) ProtoReflect ¶
func (x *Empty) ProtoReflect() protoreflect.Message
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) GetHeader ¶
func (x *FullBlock) GetHeader() *BlockHeader
func (*FullBlock) GetPayload ¶
func (*FullBlock) ProtoMessage ¶
func (*FullBlock) ProtoMessage()
func (*FullBlock) ProtoReflect ¶
func (x *FullBlock) ProtoReflect() protoreflect.Message
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) ProtoMessage ¶
func (*Peer) ProtoMessage()
func (*Peer) ProtoReflect ¶
func (x *Peer) ProtoReflect() protoreflect.Message
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) FromBlock ¶
func (s *Server) FromBlock(b *BlockID, stream AstrisV1_FromBlockServer) error
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 (*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) FromBlock ¶
func (UnimplementedAstrisV1Server) FromBlock(*BlockID, AstrisV1_FromBlockServer) error
func (UnimplementedAstrisV1Server) PeerExchange ¶
func (UnimplementedAstrisV1Server) PeerExchange(*Peer, AstrisV1_PeerExchangeServer) error
func (UnimplementedAstrisV1Server) PublishBlock ¶
func (UnimplementedAstrisV1Server) PublishBlock(context.Context, *FullBlock) (*Acceptance, error)
func (UnimplementedAstrisV1Server) RecvBlocks ¶
func (UnimplementedAstrisV1Server) RecvBlocks(*Empty, AstrisV1_RecvBlocksServer) error
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.