Documentation ¶
Index ¶
- Constants
- Variables
- func Sha256(src string) []byte
- func Verify(root H256, proof *CompiledMerkleProof, keys, values []H256) (bool, error)
- type BranchKey
- type BranchNode
- type CompiledMerkleProof
- type DefaultStore
- type H256
- func (h *H256) ClearBit(height byte)
- func (h *H256) CopyBits(height byte) *H256
- func (h *H256) CopyBits2(height byte) *H256
- func (h *H256) ForkHeight(key *H256) byte
- func (h *H256) GetBit(height byte) bool
- func (h *H256) IsRight(height byte) bool
- func (h *H256) IsZero() bool
- func (h *H256) ParentPath(height byte) *H256
- func (h *H256) SetBit(height byte)
- func (h *H256) String() string
- type JsonRpcError
- type MergeValue
- type MerkleProof
- type MongodbRoot
- type MongodbStore
- func (m *MongodbStore) Collection() *mongo.Collection
- func (m *MongodbStore) GetBranch(key BranchKey) (*BranchNode, error)
- func (m *MongodbStore) InsertBranch(key BranchKey, node BranchNode) error
- func (m *MongodbStore) RemoveBranch(key BranchKey) error
- func (m *MongodbStore) Root() (H256, error)
- func (m *MongodbStore) UpdateRoot(root H256) error
- type SmtKv
- type SmtKvHex
- type SmtOpt
- type SmtServer
- func (s *SmtServer) DeleteSmt() (bool, error)
- func (s *SmtServer) DeleteSmtWithTimeOut(timeout time.Duration) (bool, error)
- func (s *SmtServer) GetSmtRoot() (H256, error)
- func (s *SmtServer) GetSmtUrl() string
- func (s *SmtServer) UpdateMiddleSmt(kv []SmtKv, opt SmtOpt) (*UpdateMiddleSmtOut, error)
- func (s *SmtServer) UpdateSmt(kv []SmtKv, opt SmtOpt) (*UpdateSmtOut, error)
- type SortH256
- type SparseMerkleTree
- type Store
- type UpdateMiddleResult
- type UpdateMiddleSmtOut
- type UpdateResult
- type UpdateSmtOut
- type UpdateSmtParam
Constants ¶
View Source
const ( ByteSize = 8 MaxU8 = 255 MaxStackSize = 257 )
View Source
const ( MergeNormal byte = 1 MergeZeros byte = 2 PersonSparseMerkleTree = "ckb-default-hash" )
View Source
const ( GetSmtRoot = "get_smt_root" DeleteSmt = "delete_smt" UpdateMemorySmt = "update_memory_smt" UpdateDbSmt = "update_db_smt" UpdateDbSmtMiddle = "update_db_smt_middle" RetryNumber = 3 RetryTime = time.Second * 3 TimeOut = time.Second * 20 )
Variables ¶
View Source
var (
StoreErrorNotExist = errors.New("not exist")
)
Functions ¶
Types ¶
type BranchNode ¶
type BranchNode struct { Left MergeValue `json:"l" bson:"l"` Right MergeValue `json:"r" bson:"r"` }
type CompiledMerkleProof ¶
type CompiledMerkleProof []byte
func (*CompiledMerkleProof) String ¶
func (c *CompiledMerkleProof) String() string
type DefaultStore ¶
type DefaultStore struct {
// contains filtered or unexported fields
}
func (*DefaultStore) GetBranch ¶
func (d *DefaultStore) GetBranch(key BranchKey) (*BranchNode, error)
func (*DefaultStore) InsertBranch ¶
func (d *DefaultStore) InsertBranch(key BranchKey, node BranchNode) error
func (*DefaultStore) RemoveBranch ¶
func (d *DefaultStore) RemoveBranch(key BranchKey) error
func (*DefaultStore) Root ¶
func (d *DefaultStore) Root() (H256, error)
func (*DefaultStore) UpdateRoot ¶
func (d *DefaultStore) UpdateRoot(root H256) error
type H256 ¶
type H256 []byte
func AccountIdToSmtH256 ¶
func HashBaseNode ¶
func (*H256) ForkHeight ¶
func (*H256) ParentPath ¶
type JsonRpcError ¶ added in v1.0.1
type MergeValue ¶
type MergeValue struct { Value H256 `json:"v" bson:"v"` BaseNode H256 `json:"n" bson:"n"` ZeroBits H256 `json:"b" bson:"b"` ZeroCount byte `json:"c" bson:"c"` }
func Merge ¶
func Merge(height byte, nodeKey H256, lhs, rhs MergeValue) MergeValue
func MergeValueFromH256 ¶
func MergeValueFromH256(value H256) MergeValue
func MergeValueFromZero ¶
func MergeValueFromZero() MergeValue
func MergeWithZero ¶
func MergeWithZero(height byte, nodeKey H256, value MergeValue, setBit bool) MergeValue
func (*MergeValue) Hash ¶
func (m *MergeValue) Hash() H256
func (*MergeValue) IsZero ¶
func (m *MergeValue) IsZero() bool
func (*MergeValue) String ¶
func (m *MergeValue) String() string
type MerkleProof ¶
type MerkleProof struct { LeavesBitmap []H256 MerklePath []MergeValue }
type MongodbRoot ¶
type MongodbRoot struct {
Root H256 `json:"r" bson:"r"`
}
type MongodbStore ¶
type MongodbStore struct {
// contains filtered or unexported fields
}
func NewMongoStore ¶
func (*MongodbStore) Collection ¶
func (m *MongodbStore) Collection() *mongo.Collection
func (*MongodbStore) GetBranch ¶
func (m *MongodbStore) GetBranch(key BranchKey) (*BranchNode, error)
func (*MongodbStore) InsertBranch ¶
func (m *MongodbStore) InsertBranch(key BranchKey, node BranchNode) error
func (*MongodbStore) RemoveBranch ¶
func (m *MongodbStore) RemoveBranch(key BranchKey) error
func (*MongodbStore) Root ¶
func (m *MongodbStore) Root() (H256, error)
func (*MongodbStore) UpdateRoot ¶
func (m *MongodbStore) UpdateRoot(root H256) error
type SmtServer ¶ added in v1.0.1
type SmtServer struct {
// contains filtered or unexported fields
}
func (*SmtServer) DeleteSmtWithTimeOut ¶ added in v1.0.1
func (*SmtServer) GetSmtRoot ¶ added in v1.0.1
func (*SmtServer) UpdateMiddleSmt ¶ added in v1.0.1
func (s *SmtServer) UpdateMiddleSmt(kv []SmtKv, opt SmtOpt) (*UpdateMiddleSmtOut, error)
type SparseMerkleTree ¶
type SparseMerkleTree struct {
// contains filtered or unexported fields
}
func NewSparseMerkleTree ¶
func NewSparseMerkleTree(store Store) *SparseMerkleTree
func (*SparseMerkleTree) MerkleProof ¶
func (s *SparseMerkleTree) MerkleProof(keys, values []H256) (*CompiledMerkleProof, error)
func (*SparseMerkleTree) Root ¶
func (s *SparseMerkleTree) Root() (H256, error)
func (*SparseMerkleTree) Update ¶
func (s *SparseMerkleTree) Update(key, value H256) error
type UpdateMiddleResult ¶ added in v1.0.1
type UpdateMiddleSmtOut ¶ added in v1.0.1
type UpdateResult ¶ added in v1.0.1
type UpdateSmtOut ¶ added in v1.0.1
type UpdateSmtParam ¶ added in v1.0.1
Click to show internal directories.
Click to hide internal directories.