Documentation ¶
Index ¶
- Constants
- Variables
- func GRPCDialer(h host.Host, proto ...protocol.ID) func(context.Context, string) (net.Conn, error)
- func RegisterBlockStoreServer(s *grpc.Server, srv BlockStoreServer)
- type BlockMsg
- func (*BlockMsg) Descriptor() ([]byte, []int)deprecated
- func (x *BlockMsg) GetBlock() *block.Block
- func (x *BlockMsg) GetError() string
- func (x *BlockMsg) GetSender() string
- func (*BlockMsg) ProtoMessage()
- func (x *BlockMsg) ProtoReflect() protoreflect.Message
- func (x *BlockMsg) Reset()
- func (x *BlockMsg) String() string
- type BlockReq
- type BlockStoreClient
- type BlockStoreServer
- type Empty
- type Node
- func (n *Node) Base(ctx context.Context, e *Empty) (*BlockMsg, error)
- func (n *Node) BroadcastTx(tx *block.Transaction) error
- func (n *Node) Close() error
- func (n *Node) GetBlock(ctx context.Context, req *BlockReq) (*BlockMsg, error)
- func (n *Node) GetHeadBlock() (*block.Block, error)
- func (n *Node) GetTx(ctx context.Context, req *TxReq) (*TxMsg, error)
- func (n *Node) Head(ctx context.Context, e *Empty) (*BlockMsg, error)
- func (n *Node) Mined(ctx context.Context, msg *BlockMsg) (*Status, error)
- func (n *Node) PeerAddrs() []multiaddr.Multiaddr
- func (n *Node) Peers() peer.IDSlice
- func (n *Node) Start() error
- func (n *Node) StartWithGRPC(srv *grpc.Server, proto protocol.ID) error
- func (n *Node) Sync() error
- func (n *Node) Tx(ctx context.Context, msg *TxMsg) (*Status, error)
- type Status
- type Status_StatusCode
- func (Status_StatusCode) Descriptor() protoreflect.EnumDescriptor
- func (x Status_StatusCode) Enum() *Status_StatusCode
- func (Status_StatusCode) EnumDescriptor() ([]byte, []int)deprecated
- func (x Status_StatusCode) Number() protoreflect.EnumNumber
- func (x Status_StatusCode) String() string
- func (Status_StatusCode) Type() protoreflect.EnumType
- type TxMsg
- func (*TxMsg) Descriptor() ([]byte, []int)deprecated
- func (x *TxMsg) GetError() string
- func (x *TxMsg) GetSender() string
- func (x *TxMsg) GetTx() *block.Transaction
- func (*TxMsg) ProtoMessage()
- func (x *TxMsg) ProtoReflect() protoreflect.Message
- func (x *TxMsg) Reset()
- func (x *TxMsg) String() string
- type TxReq
- type UnimplementedBlockStoreServer
- func (*UnimplementedBlockStoreServer) Base(context.Context, *Empty) (*BlockMsg, error)
- func (*UnimplementedBlockStoreServer) GetBlock(context.Context, *BlockReq) (*BlockMsg, error)
- func (*UnimplementedBlockStoreServer) GetTx(context.Context, *TxReq) (*TxMsg, error)
- func (*UnimplementedBlockStoreServer) Head(context.Context, *Empty) (*BlockMsg, error)
- func (*UnimplementedBlockStoreServer) Mined(context.Context, *BlockMsg) (*Status, error)
- func (*UnimplementedBlockStoreServer) Tx(context.Context, *TxMsg) (*Status, error)
Constants ¶
const ( // DiscoveryTag is the mDNS discovery service tag DiscoveryTag = "vine._tcp" // DiscoveryTime is the time that the discovery service waits // between restarts DiscoveryTime = time.Second * 30 // GRPCProto is the default gRPC protocol GRPCProto = "/vine/grpc/0.1" )
Variables ¶
var ( Status_StatusCode_name = map[int32]string{ 0: "Ok", 1: "Err", } Status_StatusCode_value = map[string]int32{ "Ok": 0, "Err": 1, } )
Enum value maps for Status_StatusCode.
var File_node_proto protoreflect.FileDescriptor
Functions ¶
func GRPCDialer ¶
GRPCDialer creates a dialer function for use as a grpc.DialOption. A stream creator can be a host.Host from libp2p
Use with the grpc.WithContextDialer dialer option
func RegisterBlockStoreServer ¶
func RegisterBlockStoreServer(s *grpc.Server, srv BlockStoreServer)
Types ¶
type BlockMsg ¶
type BlockMsg struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` Block *block.Block `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"` Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` // contains filtered or unexported fields }
func (*BlockMsg) Descriptor
deprecated
func (*BlockMsg) ProtoMessage ¶
func (*BlockMsg) ProtoMessage()
func (*BlockMsg) ProtoReflect ¶
func (x *BlockMsg) ProtoReflect() protoreflect.Message
type BlockReq ¶
type BlockReq struct { Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` // contains filtered or unexported fields }
func (*BlockReq) Descriptor
deprecated
func (*BlockReq) ProtoMessage ¶
func (*BlockReq) ProtoMessage()
func (*BlockReq) ProtoReflect ¶
func (x *BlockReq) ProtoReflect() protoreflect.Message
type BlockStoreClient ¶
type BlockStoreClient interface { // Get a block by hash GetBlock(ctx context.Context, in *BlockReq, opts ...grpc.CallOption) (*BlockMsg, error) // Get a transaction by id GetTx(ctx context.Context, in *TxReq, opts ...grpc.CallOption) (*TxMsg, error) // Ask for the head of the chain Head(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BlockMsg, error) // Ask for the base of the chain Base(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BlockMsg, error) // Send and receive new transactions Tx(ctx context.Context, in *TxMsg, opts ...grpc.CallOption) (*Status, error) // Send and receive new mined blocks Mined(ctx context.Context, in *BlockMsg, opts ...grpc.CallOption) (*Status, error) }
BlockStoreClient is the client API for BlockStore 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 NewBlockStoreClient ¶
func NewBlockStoreClient(cc grpc.ClientConnInterface) BlockStoreClient
type BlockStoreServer ¶
type BlockStoreServer interface { // Get a block by hash GetBlock(context.Context, *BlockReq) (*BlockMsg, error) // Get a transaction by id GetTx(context.Context, *TxReq) (*TxMsg, error) // Ask for the head of the chain Head(context.Context, *Empty) (*BlockMsg, error) // Ask for the base of the chain Base(context.Context, *Empty) (*BlockMsg, error) // Send and receive new transactions Tx(context.Context, *TxMsg) (*Status, error) // Send and receive new mined blocks Mined(context.Context, *BlockMsg) (*Status, error) // contains filtered or unexported methods }
BlockStoreServer is the server API for BlockStore service. All implementations must embed UnimplementedBlockStoreServer for forward compatibility
type Empty ¶
type Empty struct {
// contains filtered or unexported fields
}
func (*Empty) Descriptor
deprecated
func (*Empty) ProtoMessage ¶
func (*Empty) ProtoMessage()
func (*Empty) ProtoReflect ¶
func (x *Empty) ProtoReflect() protoreflect.Message
type Node ¶
type Node struct { UnimplementedBlockStoreServer // contains filtered or unexported fields }
Node is a node
func (*Node) BroadcastTx ¶
func (n *Node) BroadcastTx(tx *block.Transaction) error
BroadcastTx will broadcast a transaction to all the node's peers
func (*Node) GetBlock ¶
GetBlock implement the GetBlock service for the BlockStoreServer grpc service.
func (*Node) GetHeadBlock ¶
GetHeadBlock will get the head block from the network
func (*Node) PeerAddrs ¶
func (n *Node) PeerAddrs() []multiaddr.Multiaddr
PeerAddrs will iterate through the node's peers and collect their addresses.
func (*Node) StartWithGRPC ¶
StartWithGRPC will start the node and listen for requests from the network with a grpc server.
type Status ¶
type Status struct { Code Status_StatusCode `protobuf:"varint,1,opt,name=code,proto3,enum=node.Status_StatusCode" json:"code,omitempty"` Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` // contains filtered or unexported fields }
func (*Status) Descriptor
deprecated
func (*Status) GetCode ¶
func (x *Status) GetCode() Status_StatusCode
func (*Status) ProtoMessage ¶
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶
func (x *Status) ProtoReflect() protoreflect.Message
type Status_StatusCode ¶
type Status_StatusCode int32
const ( Status_Ok Status_StatusCode = 0 Status_Err Status_StatusCode = 1 )
func (Status_StatusCode) Descriptor ¶
func (Status_StatusCode) Descriptor() protoreflect.EnumDescriptor
func (Status_StatusCode) Enum ¶
func (x Status_StatusCode) Enum() *Status_StatusCode
func (Status_StatusCode) EnumDescriptor
deprecated
func (Status_StatusCode) EnumDescriptor() ([]byte, []int)
Deprecated: Use Status_StatusCode.Descriptor instead.
func (Status_StatusCode) Number ¶
func (x Status_StatusCode) Number() protoreflect.EnumNumber
func (Status_StatusCode) String ¶
func (x Status_StatusCode) String() string
func (Status_StatusCode) Type ¶
func (Status_StatusCode) Type() protoreflect.EnumType
type TxMsg ¶
type TxMsg struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` Tx *block.Transaction `protobuf:"bytes,2,opt,name=tx,proto3" json:"tx,omitempty"` Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` // contains filtered or unexported fields }
func (*TxMsg) Descriptor
deprecated
func (*TxMsg) GetTx ¶
func (x *TxMsg) GetTx() *block.Transaction
func (*TxMsg) ProtoMessage ¶
func (*TxMsg) ProtoMessage()
func (*TxMsg) ProtoReflect ¶
func (x *TxMsg) ProtoReflect() protoreflect.Message
type TxReq ¶
type TxReq struct { Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` // contains filtered or unexported fields }
func (*TxReq) Descriptor
deprecated
func (*TxReq) ProtoMessage ¶
func (*TxReq) ProtoMessage()
func (*TxReq) ProtoReflect ¶
func (x *TxReq) ProtoReflect() protoreflect.Message
type UnimplementedBlockStoreServer ¶
type UnimplementedBlockStoreServer struct { }
UnimplementedBlockStoreServer must be embedded to have forward compatible implementations.