Closed mgravitt closed 3 years ago
I was thinking we might not need to store the contract in the edge, but It mostly dependes on how the edge and where is it going to be used. I.e we could simply send the contract as a parameter when calling the emplace/fetch function but this would require the caller to know the contract, and as said before depending on where we want to deal with the edge object this might not be posible.
About the Cross-contract edges I think it's a good idea to have them as a separated struct so we don't enforce the use of the extra slots if the contract doesn't really needs it (external usage).
The macro will need some modifications but I think we can still use that method to generate the ABI tags, the earlier we test this the better.
It looks good to me @dappdever, I didn't know that structs supported inheritance, it's a nice feature and it makes sense to use it for the cross contract edges, but would it create a new table?
We are refactoring Document and Edge classes/structs significantly for improved design, which will also enable the structure to be used in many contracts as plug-and-play. Do the below recommendations make the structure the most re-usable?
Here's the current view of what Edge would look like:
Since reading and writing to the
edge_table
will occur within the Edge class, we add thecontract
to the constructor and also as a private member. Even though we don't need contract to be saved within the table, the ABI generator automatically generates it and puts it into the table definition.If we do this, we will need migrate existing data as part of the deployment. Not a big deal, but definitely work.
Cross-contract edges
Not related to the above, but also impacts data structure. It's possible that we will need to support cross-contract edges in the future. For example, redemptions held in
bank.hypha
will likely become documents and will need to be linked to the members indao.hypha
.Due to the manner that we are indexing edges (all combinations of the columns), the indexes would grow significantly by adding two edges to each row. There are already 8 indexes, and adding two additional rows would require 16 more if we held with the same pattern. This may not be required, but would certainly add complexity.
Instead, I think we would use base ABI functionality described here: https://developers.eos.io/welcome/latest/getting-started/smart-contract-development/understanding-ABI-files/#struct-base
I have not used this before, but it seems that it allows support for inheritance. If and when needed, we would create a
CrossContractEdge
struct which would inherit fromEdge
and the two additional members and needed indexes.ABI generator tag
@Gerard097 created a Macro used in the current version to alleviate the need to edit the DocumentGraph struct definitions for each contract. Is that still compatible with the above?
Recommendation
CrossContractEdge
as a derived struct if and when needed