Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterNodeServer(s grpc.ServiceRegistrar, srv NodeServer)
- type Block
- func (*Block) Descriptor() ([]byte, []int)deprecated
- func (x *Block) GetHeader() *BlockHeader
- func (x *Block) GetPublicKey() []byte
- func (x *Block) GetSignature() []byte
- func (x *Block) GetTransactions() []*Transaction
- func (*Block) ProtoMessage()
- func (x *Block) ProtoReflect() protoreflect.Message
- func (x *Block) Reset()
- func (x *Block) String() string
- type BlockHeader
- func (*BlockHeader) Descriptor() ([]byte, []int)deprecated
- func (x *BlockHeader) GetHeight() int32
- func (x *BlockHeader) GetPrevHash() []byte
- func (x *BlockHeader) GetRootHash() []byte
- func (x *BlockHeader) GetTimestamp() int64
- func (x *BlockHeader) GetVersion() int32
- func (*BlockHeader) ProtoMessage()
- func (x *BlockHeader) ProtoReflect() protoreflect.Message
- func (x *BlockHeader) Reset()
- func (x *BlockHeader) String() string
- type NodeClient
- type NodeInfo
- func (*NodeInfo) Descriptor() ([]byte, []int)deprecated
- func (x *NodeInfo) GetHeight() int32
- func (x *NodeInfo) GetListenAddr() string
- func (x *NodeInfo) GetPeerList() []string
- func (x *NodeInfo) GetVersion() string
- func (*NodeInfo) ProtoMessage()
- func (x *NodeInfo) ProtoReflect() protoreflect.Message
- func (x *NodeInfo) Reset()
- func (x *NodeInfo) String() string
- type NodeServer
- type Transaction
- func (*Transaction) Descriptor() ([]byte, []int)deprecated
- func (x *Transaction) GetInputs() []*TxInput
- func (x *Transaction) GetOutputs() []*TxOutput
- func (x *Transaction) GetVersion() int32
- func (*Transaction) ProtoMessage()
- func (x *Transaction) ProtoReflect() protoreflect.Message
- func (x *Transaction) Reset()
- func (x *Transaction) String() string
- type TxInput
- func (*TxInput) Descriptor() ([]byte, []int)deprecated
- func (x *TxInput) GetPrevTxHash() []byte
- func (x *TxInput) GetPrevTxOutIndex() uint32
- func (x *TxInput) GetPublicKey() []byte
- func (x *TxInput) GetSignature() []byte
- func (*TxInput) ProtoMessage()
- func (x *TxInput) ProtoReflect() protoreflect.Message
- func (x *TxInput) Reset()
- func (x *TxInput) String() string
- type TxOutput
- type UnimplementedNodeServer
- type UnsafeNodeServer
Constants ¶
const ( Node_Handshake_FullMethodName = "/Node/Handshake" Node_HandleTransaction_FullMethodName = "/Node/HandleTransaction" )
Variables ¶
var File_blockchain_proto protoreflect.FileDescriptor
var Node_ServiceDesc = grpc.ServiceDesc{ ServiceName: "Node", HandlerType: (*NodeServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Handshake", Handler: _Node_Handshake_Handler, }, { MethodName: "HandleTransaction", Handler: _Node_HandleTransaction_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "blockchain.proto", }
Node_ServiceDesc is the grpc.ServiceDesc for Node service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterNodeServer ¶
func RegisterNodeServer(s grpc.ServiceRegistrar, srv NodeServer)
Types ¶
type Block ¶
type Block struct { Header *BlockHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` PublicKey []byte `protobuf:"bytes,2,opt,name=publicKey,proto3" json:"publicKey,omitempty"` Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"` Transactions []*Transaction `protobuf:"bytes,4,rep,name=transactions,proto3" json:"transactions,omitempty"` // contains filtered or unexported fields }
func (*Block) Descriptor
deprecated
func (*Block) GetHeader ¶
func (x *Block) GetHeader() *BlockHeader
func (*Block) GetPublicKey ¶
func (*Block) GetSignature ¶
func (*Block) GetTransactions ¶
func (x *Block) GetTransactions() []*Transaction
func (*Block) ProtoMessage ¶
func (*Block) ProtoMessage()
func (*Block) ProtoReflect ¶
func (x *Block) ProtoReflect() protoreflect.Message
type BlockHeader ¶
type BlockHeader struct { Version int32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` // Block height in the blockchain (sequential ID) Height int32 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` // Hash of the previous block in the chain PrevHash []byte `protobuf:"bytes,3,opt,name=prevHash,proto3" json:"prevHash,omitempty"` // Merkle root hash of all transactions in this block RootHash []byte `protobuf:"bytes,4,opt,name=rootHash,proto3" json:"rootHash,omitempty"` // Unix timestamp when the block was created Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // contains filtered or unexported fields }
func (*BlockHeader) Descriptor
deprecated
func (*BlockHeader) Descriptor() ([]byte, []int)
Deprecated: Use BlockHeader.ProtoReflect.Descriptor instead.
func (*BlockHeader) GetHeight ¶
func (x *BlockHeader) GetHeight() int32
func (*BlockHeader) GetPrevHash ¶
func (x *BlockHeader) GetPrevHash() []byte
func (*BlockHeader) GetRootHash ¶
func (x *BlockHeader) GetRootHash() []byte
func (*BlockHeader) GetTimestamp ¶
func (x *BlockHeader) GetTimestamp() int64
func (*BlockHeader) GetVersion ¶
func (x *BlockHeader) GetVersion() int32
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 NodeClient ¶
type NodeClient interface { Handshake(ctx context.Context, in *NodeInfo, opts ...grpc.CallOption) (*NodeInfo, error) HandleTransaction(ctx context.Context, in *Transaction, opts ...grpc.CallOption) (*emptypb.Empty, error) }
NodeClient is the client API for Node 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 NewNodeClient ¶
func NewNodeClient(cc grpc.ClientConnInterface) NodeClient
type NodeInfo ¶
type NodeInfo struct { Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` Height int32 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` // listenAddr is an address the node is listening on for connections. ListenAddr string `protobuf:"bytes,3,opt,name=listenAddr,proto3" json:"listenAddr,omitempty"` PeerList []string `protobuf:"bytes,4,rep,name=peerList,proto3" json:"peerList,omitempty"` // contains filtered or unexported fields }
func (*NodeInfo) Descriptor
deprecated
func (*NodeInfo) GetListenAddr ¶
func (*NodeInfo) GetPeerList ¶
func (*NodeInfo) GetVersion ¶
func (*NodeInfo) ProtoMessage ¶
func (*NodeInfo) ProtoMessage()
func (*NodeInfo) ProtoReflect ¶
func (x *NodeInfo) ProtoReflect() protoreflect.Message
type NodeServer ¶
type NodeServer interface { Handshake(context.Context, *NodeInfo) (*NodeInfo, error) HandleTransaction(context.Context, *Transaction) (*emptypb.Empty, error) // contains filtered or unexported methods }
NodeServer is the server API for Node service. All implementations must embed UnimplementedNodeServer for forward compatibility.
type Transaction ¶
type Transaction struct { Version int32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` Inputs []*TxInput `protobuf:"bytes,2,rep,name=inputs,proto3" json:"inputs,omitempty"` Outputs []*TxOutput `protobuf:"bytes,3,rep,name=outputs,proto3" json:"outputs,omitempty"` // contains filtered or unexported fields }
func (*Transaction) Descriptor
deprecated
func (*Transaction) Descriptor() ([]byte, []int)
Deprecated: Use Transaction.ProtoReflect.Descriptor instead.
func (*Transaction) GetInputs ¶
func (x *Transaction) GetInputs() []*TxInput
func (*Transaction) GetOutputs ¶
func (x *Transaction) GetOutputs() []*TxOutput
func (*Transaction) GetVersion ¶
func (x *Transaction) GetVersion() int32
func (*Transaction) ProtoMessage ¶
func (*Transaction) ProtoMessage()
func (*Transaction) ProtoReflect ¶
func (x *Transaction) ProtoReflect() protoreflect.Message
func (*Transaction) Reset ¶
func (x *Transaction) Reset()
func (*Transaction) String ¶
func (x *Transaction) String() string
type TxInput ¶
type TxInput struct { // prevTxHash is the hash of the previous transaction that this input is spending from. PrevTxHash []byte `protobuf:"bytes,1,opt,name=prevTxHash,proto3" json:"prevTxHash,omitempty"` // prevTxOutIndex (UTXO id) is the index of the output in the previous transaction that this input is spending from. PrevTxOutIndex uint32 `protobuf:"varint,2,opt,name=prevTxOutIndex,proto3" json:"prevTxOutIndex,omitempty"` PublicKey []byte `protobuf:"bytes,3,opt,name=publicKey,proto3" json:"publicKey,omitempty"` // signature signs the transaction hash and the public key of the sender. Signature []byte `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty"` // contains filtered or unexported fields }
func (*TxInput) Descriptor
deprecated
func (*TxInput) GetPrevTxHash ¶
func (*TxInput) GetPrevTxOutIndex ¶
func (*TxInput) GetPublicKey ¶
func (*TxInput) GetSignature ¶
func (*TxInput) ProtoMessage ¶
func (*TxInput) ProtoMessage()
func (*TxInput) ProtoReflect ¶
func (x *TxInput) ProtoReflect() protoreflect.Message
type TxOutput ¶
type TxOutput struct { Amount int64 `protobuf:"varint,1,opt,name=amount,proto3" json:"amount,omitempty"` // Address of the recipient Address []byte `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // contains filtered or unexported fields }
func (*TxOutput) Descriptor
deprecated
func (*TxOutput) GetAddress ¶
func (*TxOutput) ProtoMessage ¶
func (*TxOutput) ProtoMessage()
func (*TxOutput) ProtoReflect ¶
func (x *TxOutput) ProtoReflect() protoreflect.Message
type UnimplementedNodeServer ¶
type UnimplementedNodeServer struct{}
UnimplementedNodeServer must be embedded to have forward compatible implementations.
NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.
func (UnimplementedNodeServer) HandleTransaction ¶
func (UnimplementedNodeServer) HandleTransaction(context.Context, *Transaction) (*emptypb.Empty, error)
type UnsafeNodeServer ¶
type UnsafeNodeServer interface {
// contains filtered or unexported methods
}
UnsafeNodeServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to NodeServer will result in compilation errors.