blizcore

package
v0.0.0-...-e1f35ab Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

NodeID 和 publicKey 之间的互相转换参见 /p2p/discover 下的 node.go func PubkeyID(pub *ecdsa.PublicKey) NodeID {} func (id NodeID) Pubkey() (*ecdsa.PublicKey, error) {} 两个函数

Index

Constants

View Source
const (
	ReqData = 0
	ReqHash = 1
)

Variables

This section is empty.

Functions

func BlizHash

func BlizHash(data []byte) []byte

func CommonHash

func CommonHash(x interface{}) (h common.Hash)

common sign start

func CommonSender

func CommonSender(h common.Hash, sign []byte) (common.Address, error)

func CommonSign

func CommonSign(h common.Hash, prv *ecdsa.PrivateKey) ([]byte, error)

func EcRecover

func EcRecover(data, sig []byte) (common.Address, error)

func ErrorToUInt8

func ErrorToUInt8(e error) uint8

func RecoverBase

func RecoverBase(addr common.Address, deadline uint64, r, s, v *big.Int) (common.Address, error)

func RlpHash

func RlpHash(x interface{}) (h common.Hash)

func SignWop

func SignWop(wop *WriteOperReqData, prv *ecdsa.PrivateKey) error

SignTx signs the transaction using the given signer and private key

Types

type BlizObjectMeta

type BlizObjectMeta struct {
	Name       string         // 名称
	Length     uint64         // 长度
	Permission uint64         // (rw)权限
	Owner      common.Address // 对象属主(tenant)

	// 根据 length 可以计算出当前占用了多少个 slice
	SliceInfos []SliceInfo // 内容所在的所有slice信息
}

BlizObjectMeta 包含在该对象对应的 chunk:slice 世界状态 指向的存储区域,从该存储区域的一个slice(1M)获取到所有的 对象信息

func (*BlizObjectMeta) Equal

func (a *BlizObjectMeta) Equal(b *BlizObjectMeta) bool

type BuffFromSharerCSData

type BuffFromSharerCSData struct {
	ID   string
	Buff []byte
}

type DataQuery

type DataQuery interface {
	SetQuerId(queryId uint64)
}

query 类消息

type DiscReason

type DiscReason uint
const (
	DiscRequested DiscReason = iota
	DiscNetworkError
	DiscProtocolError
	DiscUselessPeer
	DiscTooManyPeers
	DiscAlreadyConnected
	DiscIncompatibleVersion
	DiscInvalidIdentity
	DiscQuitting
	DiscUnexpectedIdentity
	DiscSelf
	DiscReadTimeout
	DiscSubprotocolError = 0x10
)

func (DiscReason) Error

func (d DiscReason) Error() string

func (DiscReason) String

func (d DiscReason) String() string

type ErrCode

type ErrCode int
const (
	ErrMsgTooLarge ErrCode = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrInvalidMsgParameter
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
	ErrNoDailChunkInfo
	ErrNoShakeHandsChunkInfo
	ErrChunkMismatch
	ErrLocalNotChunkFarmer
	ErrPartnerNotChunkFarmer
	ErrAssoAlreadyExist

	ErrRetriveFarmerFail
	ErrInsufficientFarmers
	ErrQueryShardingMinerTimeout
	ErrQueryFarmerTimeout
	ErrQueryObjectMetaTimeout

	ErrObjectSpaceInsufficient
	ErrWouldBlock
	ErrParameter
	ErrHash
	ErrFarmer
	ErrNetwork

	ErrWopIdNotValid
	ErrWopInvalidPermission
	ErrInvalidSig

	ErrOutOfRange
	ErrTimeout
	ErrNoEnoughFarmer
	ErrLackOfData
	ErrCapacityNotEnough
	ErrWriteOperRsp
	ErrFarmerSlice
	ErrReadOperRsp
	ErrSliceHeader

	ErrRsv
	ErrRsvTimeout

	ErrUnknown // 务必放在最后
)

func UInt8ToErrorCode

func UInt8ToErrorCode(id uint8) ErrCode

func (ErrCode) Error

func (e ErrCode) Error() string

func (ErrCode) String

func (e ErrCode) String() string

type FarmerSliceOp

type FarmerSliceOp struct {
	ChunkId uint64
	SliceId uint32
	OpId    uint64
}

type FarmerSliceOpReq

type FarmerSliceOpReq struct {
	ObjUId     string
	SliceInfos []SliceInfo
}

type FarmerSliceOpRsp

type FarmerSliceOpRsp struct {
	ObjUId         string
	FarmerSliceOps []FarmerSliceOp
	NodeId         discover.NodeID
}

type GetBuffFromSharerCSData

type GetBuffFromSharerCSData struct {
	Sharer    string
	ObjId     uint64
	Offset    uint64
	Len       uint64
	SigPeerId string
}

type GetHeaderHashMsgData

type GetHeaderHashMsgData struct {
	Chunk uint64
	Slice uint32
}

type GetSegmentDataMsgData

type GetSegmentDataMsgData struct {
	Chunk   uint64
	Slice   uint32
	Segment uint32 // 获取的起始 Segment index
	Count   uint32 // 获取 Segment 数量

	QueryId uint64
}

func (*GetSegmentDataMsgData) SetQuerId

func (query *GetSegmentDataMsgData) SetQuerId(queryId uint64)

type GetSliceInfoMsgData

type GetSliceInfoMsgData struct {
	Chunk uint64
	Slice uint32

	QueryId uint64
}

func (*GetSliceInfoMsgData) SetQuerId

func (query *GetSliceInfoMsgData) SetQuerId(queryId uint64)

type GetSliceMetaFromFarmerReqData

type GetSliceMetaFromFarmerReqData struct {
	Address common.Address
}

type GetWriteDataMsgData

type GetWriteDataMsgData struct {
	Chunk uint64
	Slice uint32
}

type GetWriteOpMsgData

type GetWriteOpMsgData struct {
	Chunk     uint64
	Slice     uint32
	FromWopId uint64
	Count     uint32 // 暂时不考虑,默认为1

	QueryId uint64
}

func (*GetWriteOpMsgData) SetQuerId

func (query *GetWriteOpMsgData) SetQuerId(queryId uint64)

type HeaderHashMsgData

type HeaderHashMsgData struct {
	Rsp        *GetHeaderHashMsgData
	HeaderHash common.Hash
	OpId       uint64
}

type HeartBeatMsgData

type HeartBeatMsgData struct {
	Ts      uint64
	ChunkId uint64
	Progs   []*SliceWopProg

	// Signature values( for Id & Hash(Datas) & Infos & Chunk & Slice)
	Signature []byte
}

func (*HeartBeatMsgData) Hash

func (hbdata *HeartBeatMsgData) Hash() common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (*HeartBeatMsgData) Sender

func (hbdata *HeartBeatMsgData) Sender() (discover.NodeID, error)

func (*HeartBeatMsgData) SignHeartbeat

func (hbdata *HeartBeatMsgData) SignHeartbeat(prv *ecdsa.PrivateKey) error

type ReadOperReqData

type ReadOperReqData struct {
	Id     uint64
	Chunk  uint64
	Slice  uint32
	Offset uint32
	Length uint32
	Type   uint8 // 0: data, 1: hash
	NodeId discover.NodeID
	ObjId  string
}

type ReadOperRspData

type ReadOperRspData struct {
	ReadOperReqData
	ErrBytes []byte
	Data     []byte
}

type SegmentDataMsgData

type SegmentDataMsgData struct {
	Chunk   uint64
	Slice   uint32
	Segment uint32 // 返回的起始 Segment Index
	Count   uint32 // 获取 Segment 数量

	QueryId uint64
	// contains filtered or unexported fields
}

type SliceInfo

type SliceInfo struct {
	ChunkId uint64
	SliceId uint32
}

implement the client part of Blizzard Service

func (*SliceInfo) ChunkString

func (si *SliceInfo) ChunkString() string

func (*SliceInfo) String

func (si *SliceInfo) String() string

type SliceInfoMsgData

type SliceInfoMsgData struct {
	Chunk uint64
	Slice uint32

	QueryId uint64

	WopProg      uint64   // 当前slice的 wopId 进度
	SegmentHashs [][]byte // 当前slice中所有 segment 的 hash 值列表

	Signature []byte // tenant 为 WopProg + Hash(SegmentHashs) 的签名,可以由上面两个值来计算校验
}

func (*SliceInfoMsgData) Verify

func (msgdata *SliceInfoMsgData) Verify() error

校验 Signature 和 WopProg + Hash(SegmentHashs) 是否对的上

type SliceWopProg

type SliceWopProg struct {
	Slice uint32
	WopId uint64
}

type WopData

type WopData struct {
	WopId uint64
}

type WopInfo

type WopInfo struct {
	WopId uint64
	WopTs uint64

	Chunk uint64 // 该 Wop 涉及的Chunk:Slice
	Slice uint32

	Infos *[]*WriteDataInfoS // 一组写入数据的相关Info

	Type       uint8 // 0: write data, 1: checked header hash
	HeaderHash common.Hash

	// Signature values( for Id & Hash(Datas) & Infos & Chunk & Slice)
	V *big.Int //`json:"v" gencodec:"required"`
	R *big.Int //`json:"r" gencodec:"required"`
	S *big.Int //`json:"s" gencodec:"required"`

	AuthAddress   common.Address
	AuthDeadlineC uint64
	RC            *big.Int // comming from client
	SC            *big.Int // comming from client
	VC            *big.Int // comming from client
}

func (*WopInfo) AuthHash

func (wop *WopInfo) AuthHash() common.Hash

func (*WopInfo) AuthSender

func (wop *WopInfo) AuthSender() (common.Address, error)

func (*WopInfo) Hash

func (wop *WopInfo) Hash() common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (*WopInfo) Sender

func (wop *WopInfo) Sender() (common.Address, error)

type WriteDataInfoS

type WriteDataInfoS struct {
	Offset uint32
	Length uint32
	Hash   []byte // Data 的 hash, 取末尾4字节
}

WOP 定义

type WriteDataMsgData

type WriteDataMsgData struct {
	Rsp    *GetWriteDataMsgData
	Header *storagecore.SliceHeader
	Data   []byte
}

type WriteOpMsgData

type WriteOpMsgData struct {
	QueryId uint64

	Info  *WopInfo
	Datas [][]byte // 一组写入数据(跟Infos一一对应)
}

基本跟 WriteOperReqData 一样

type WriteOperReqData

type WriteOperReqData struct {
	Info   *WopInfo
	Datas  [][]byte // 一组写入数据(跟Infos一一对应)
	ObjUId string
	Sign   []byte
}

func (*WriteOperReqData) AuthSender

func (req *WriteOperReqData) AuthSender() (common.Address, error)

func (*WriteOperReqData) AuthVerifySeal

func (wop *WriteOperReqData) AuthVerifySeal(tenant common.Address) error

func (*WriteOperReqData) Hash

func (req *WriteOperReqData) Hash() common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (*WriteOperReqData) Sender

func (req *WriteOperReqData) Sender() (common.Address, error)

func (*WriteOperReqData) SignatureValues

func (wop *WriteOperReqData) SignatureValues(sig []byte) (r, s, v *big.Int, err error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

func (*WriteOperReqData) VerifySeal

func (wop *WriteOperReqData) VerifySeal(tenant common.Address) error

计算 Datas 的hash值

func (*WriteOperReqData) WithSignature

func (wop *WriteOperReqData) WithSignature(sig []byte) error

WithSignature returns a new transaction with the given signature. This signature needs to be formatted as described in the yellow paper (v+27).

type WriteOperRspData

type WriteOperRspData struct {
	Chunk      uint64
	Slice      uint32
	Id         uint64 // WopId
	Status     uint32 // return status: success or fail
	ErrBytes   []byte
	Type       uint8       // 0: write data, 1: checked data hash, stored at local
	HeaderHash common.Hash // for signing
	ObjUId     string
	Infos      *[]*WriteDataInfoS
}

Jump to

Keyboard shortcuts

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