| 676 | */ |
| 677 | |
| 678 | void ProxyRunner::process_db_key(td::Slice key, td::Slice value, std::shared_ptr<RunnerConfig> runner_config) { |
| 679 | auto key_parts = td::split(key, '_'); |
| 680 | auto key_type = key_parts.first; |
| 681 | key = key_parts.second; |
| 682 | |
| 683 | CHECK(value.size() >= 64); |
| 684 | auto signature = value.copy().remove_prefix(value.size() - 64); |
| 685 | value.remove_suffix(64); |
| 686 | |
| 687 | public_key_obj_->verify_signature(value, signature).ensure(); |
| 688 | |
| 689 | if (key_type == "client") { |
| 690 | block::StdAddress client_owner_address; |
| 691 | CHECK(rdeserialize(client_owner_address, key)); |
| 692 | auto client_owner_address_str = client_owner_address.rserialize(true); |
| 693 | |
| 694 | auto obj = cocoon::fetch_tl_object<cocoon_api::proxyDb_ClientInfo>(value, true).move_as_ok(); |
| 695 | |
| 696 | auto client_info = std::make_shared<ProxyClientInfo>(this, *obj, runner_config); |
| 697 | CHECK(clients_.emplace(client_owner_address_str, std::move(client_info)).second); |
| 698 | } else if (key_type == "worker") { |
| 699 | block::StdAddress worker_owner_address; |
| 700 | CHECK(rdeserialize(worker_owner_address, key)); |
| 701 | auto worker_owner_address_str = worker_owner_address.rserialize(true); |
| 702 | |
| 703 | auto obj = cocoon::fetch_tl_object<cocoon_api::proxyDb_workerInfo>(value, true).move_as_ok(); |
| 704 | |
| 705 | auto worker_info = std::make_shared<ProxyWorkerInfo>(this, *obj, runner_config); |
| 706 | CHECK(workers_.emplace(worker_owner_address_str, std::move(worker_info)).second); |
| 707 | } else if (key_type == "config") { |
| 708 | } else if (key_type == "oldproxycontract") { |
| 709 | block::StdAddress sc_addr; |
| 710 | CHECK(rdeserialize(sc_addr, key)); |
| 711 | |
| 712 | auto obj = cocoon::fetch_tl_object<cocoon_api::proxyDb_oldInstance>(value, true).move_as_ok(); |
| 713 | auto old_instance = std::make_shared<OldProxyContract>(*obj, this); |
| 714 | |
| 715 | CHECK(old_proxy_contracts_.emplace(sc_addr.rserialize(true), std::move(old_instance)).second); |
| 716 | } else if (key_type == "oldclient") { |
| 717 | } else if (key_type == "oldworker") { |
| 718 | } else { |
| 719 | LOG(FATAL) << "unknown key type in db: " << key; |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | void ProxyRunner::client_to_db(ProxyClientInfo &client) { |
| 724 | auto key = PSTRING() << "client_" << client.client_owner_address().rserialize(true); |
nothing calls this directly
no test coverage detected