-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
2,535 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
components/brave_wallet/browser/internal/orchard_shard_tree_manager.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/components/brave_wallet/browser/internal/orchard_shard_tree_manager.h" | ||
|
||
#include "brave/components/brave_wallet/common/zcash_utils.h" | ||
|
||
namespace brave_wallet { | ||
|
||
// static | ||
std::unique_ptr<OrchardShardTreeManager> OrchardShardTreeManager::Create( | ||
std::unique_ptr<OrchardShardTreeDelegate> delegate) { | ||
auto shard_tree = orchard::OrchardShardTree::Create(std::move(delegate)); | ||
if (!shard_tree) { | ||
// NOTREACHED | ||
return nullptr; | ||
} | ||
return std::make_unique<OrchardShardTreeManager>(std::move(shard_tree)); | ||
} | ||
|
||
OrchardShardTreeManager::OrchardShardTreeManager( | ||
std::unique_ptr<::brave_wallet::orchard::OrchardShardTree> shard_tree) { | ||
orchard_shard_tree_ = std::move(shard_tree); | ||
} | ||
|
||
OrchardShardTreeManager::~OrchardShardTreeManager() {} | ||
|
||
bool OrchardShardTreeManager::InsertCommitments( | ||
std::vector<OrchardCommitment> commitments) { | ||
return orchard_shard_tree_->InsertCommitments(std::move(commitments)); | ||
} | ||
|
||
bool OrchardShardTreeManager::InsertSubtreeRoots( | ||
std::vector<OrchardShard> roots) { | ||
return orchard_shard_tree_->InsertSubtreeRoots(std::move(roots)); | ||
} | ||
|
||
} // namespace brave_wallet |
34 changes: 34 additions & 0 deletions
34
components/brave_wallet/browser/internal/orchard_shard_tree_manager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_INTERNAL_ORCHARD_SHARD_TREE_MANAGER_H_ | ||
#define BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_INTERNAL_ORCHARD_SHARD_TREE_MANAGER_H_ | ||
|
||
#include "base/types/expected.h" | ||
#include "brave/components/brave_wallet/browser/zcash/rust/orchard_block_decoder.h" | ||
#include "brave/components/brave_wallet/browser/zcash/rust/orchard_shard_tree.h" | ||
#include "brave/components/brave_wallet/common/zcash_utils.h" | ||
|
||
namespace brave_wallet { | ||
|
||
class OrchardShardTreeManager { | ||
public: | ||
OrchardShardTreeManager( | ||
std::unique_ptr<::brave_wallet::orchard::OrchardShardTree> shard_tree); | ||
~OrchardShardTreeManager(); | ||
bool InsertCommitments(std::vector<OrchardCommitment> commitments); | ||
bool InsertSubtreeRoots(std::vector<OrchardShard> roots); | ||
|
||
static std::unique_ptr<OrchardShardTreeManager> Create( | ||
std::unique_ptr<OrchardShardTreeDelegate> delegate); | ||
|
||
private: | ||
std::unique_ptr<::brave_wallet::orchard::OrchardShardTree> | ||
orchard_shard_tree_; | ||
}; | ||
|
||
} // namespace brave_wallet | ||
|
||
#endif // BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_INTERNAL_ORCHARD_SHARD_TREE_MANAGER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
components/brave_wallet/browser/zcash/rust/cxx/src/shard_store.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// you can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#ifndef BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_ZCASH_RUST_CXX_SRC_SHARD_STORE_H_ | ||
#define BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_ZCASH_RUST_CXX_SRC_SHARD_STORE_H_ | ||
|
||
#include "brave/components/brave_wallet/common/zcash_utils.h" | ||
#include "third_party/rust/cxx/v1/cxx.h" | ||
|
||
namespace brave_wallet::orchard { | ||
|
||
enum class ShardStoreStatusCode : uint32_t; | ||
struct FfiShardTree; | ||
struct FfiShardAddress; | ||
struct FfiCheckpoint; | ||
struct FfiCap; | ||
|
||
using ShardStoreContext = ::brave_wallet::OrchardShardTreeDelegate; | ||
|
||
ShardStoreStatusCode orchard_last_shard(const ShardStoreContext& ctx, | ||
FfiShardTree& into); | ||
ShardStoreStatusCode orchard_put_shard(ShardStoreContext& ctx, | ||
const FfiShardTree& tree); | ||
ShardStoreStatusCode orchard_get_shard(const ShardStoreContext& ctx, | ||
const FfiShardAddress& addr, | ||
FfiShardTree& tree); | ||
ShardStoreStatusCode orchard_get_shard_roots( | ||
const ShardStoreContext& ctx, | ||
::rust::Vec<FfiShardAddress>& into); | ||
ShardStoreStatusCode orchard_truncate(ShardStoreContext& ctx, | ||
const FfiShardAddress& address); | ||
ShardStoreStatusCode orchard_get_cap(const ShardStoreContext& ctx, | ||
FfiCap& into); | ||
ShardStoreStatusCode orchard_put_cap(ShardStoreContext& ctx, | ||
const FfiCap& tree); | ||
ShardStoreStatusCode orchard_min_checkpoint_id(const ShardStoreContext& ctx, uint32_t& into); | ||
ShardStoreStatusCode orchard_max_checkpoint_id(const ShardStoreContext& ctx, uint32_t& into); | ||
ShardStoreStatusCode orchard_add_checkpoint(ShardStoreContext& ctx, | ||
uint32_t checkpoint_id, | ||
const FfiCheckpoint& checkpoint); | ||
ShardStoreStatusCode orchard_checkpoint_count(const ShardStoreContext& ctx, size_t& into); | ||
ShardStoreStatusCode orchard_get_checkpoint_at_depth( | ||
const ShardStoreContext& ctx, | ||
size_t depth, | ||
uint32_t& into_checkpoint_id, | ||
FfiCheckpoint& into_checpoint); | ||
ShardStoreStatusCode orchard_get_checkpoint(const ShardStoreContext& ctx, | ||
uint32_t checkpoint_id, | ||
FfiCheckpoint& into); | ||
ShardStoreStatusCode orchard_update_checkpoint( | ||
ShardStoreContext& ctx, | ||
uint32_t checkpoint_id, | ||
const FfiCheckpoint& checkpoint); | ||
ShardStoreStatusCode orchard_remove_checkpoint(ShardStoreContext& ctx, | ||
uint32_t checkpoint_id); | ||
ShardStoreStatusCode orchard_truncate_checkpoint(ShardStoreContext& ctx, | ||
uint32_t checkpoint_id); | ||
ShardStoreStatusCode orchard_with_checkpoints(const ShardStoreContext& ctx, | ||
size_t limit, | ||
rust::cxxbridge1::Fn<ShardStoreStatusCode(uint32_t checkpoint_id, | ||
const FfiCheckpoint& checkpoint)> fn); | ||
ShardStoreStatusCode orchard_get_checkpoints(const ShardStoreContext& ctx, | ||
size_t limit, | ||
::rust::Vec<FfiCheckpoint>& into); | ||
|
||
} // namespace brave_wallet::orchard | ||
|
||
#endif // BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_ZCASH_RUST_CXX_SRC_SHARD_STORE_H_ |
Oops, something went wrong.