Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

WIP: 128 hash table mock #136

Merged
merged 52 commits into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3b79563
stub HashTable trait
thedavidmeister Jul 11, 2018
6c85a67
move entry header and pair into hash table
thedavidmeister Jul 11, 2018
bba3db3
implement commit and get for memtable
thedavidmeister Jul 11, 2018
cc7c72d
WIP on hash table refactor
thedavidmeister Jul 11, 2018
3524de1
WIP on hashtable refactor
thedavidmeister Jul 11, 2018
abb3d31
WIP on hash table pair meta data
thedavidmeister Jul 12, 2018
a9cba22
Merge commit 'fd3b482c2b2c444fd0bdda2856f67a4ef82f81b5' into 128-hash…
thedavidmeister Jul 12, 2018
ec32607
hash table implementation WIP
thedavidmeister Jul 12, 2018
d682c12
WIP on fixing tests for chains
thedavidmeister Jul 12, 2018
337c33f
test for chain table
thedavidmeister Jul 12, 2018
1c9191c
Rc based chain table
thedavidmeister Jul 17, 2018
1b174a5
remove objekt
thedavidmeister Jul 17, 2018
ccb1dff
remove objekt
thedavidmeister Jul 17, 2018
f4166bf
basic tests for AgentState
thedavidmeister Jul 17, 2018
ae111bd
lint
thedavidmeister Jul 17, 2018
36d4625
reinstate chain.top() tests
thedavidmeister Jul 17, 2018
dae4ea2
reinstate tests for chain.push
thedavidmeister Jul 17, 2018
b97a29c
lint
thedavidmeister Jul 17, 2018
2ee9e28
reinstante validate tests for chain
thedavidmeister Jul 18, 2018
cd1f2d7
WIP on iter() test
thedavidmeister Jul 18, 2018
50b9ee2
reinstate iter_functional() for chain tests
thedavidmeister Jul 18, 2018
7044e52
reinstate tests for chain.get()
thedavidmeister Jul 18, 2018
161ffdf
reinstate tests for chain.get_entry()
thedavidmeister Jul 18, 2018
f7e8fdd
reinstate tests for chain.top_type()
thedavidmeister Jul 18, 2018
2e06d4a
implement and test clone based chain.into_iter()
thedavidmeister Jul 18, 2018
748b5c7
tests for chain.to_json()
thedavidmeister Jul 18, 2018
f9bedc4
reimplement json round trip for chain
thedavidmeister Jul 18, 2018
58be280
lint
thedavidmeister Jul 18, 2018
c1a8cd4
tests for serializable_to_b58_hash
thedavidmeister Jul 18, 2018
741aab9
tests for pair meta
thedavidmeister Jul 18, 2018
e3b7c27
constants for STATUS_NAME and LINK_NAME for crud meta
thedavidmeister Jul 18, 2018
b1e19a0
basic getters for PairMeta
thedavidmeister Jul 18, 2018
1e32c09
tests for modify meta in hash table
thedavidmeister Jul 18, 2018
d88164b
test for retract metadata in hash table
thedavidmeister Jul 18, 2018
f536596
basic tests for get_pair_meta
thedavidmeister Jul 18, 2018
3590256
lint
thedavidmeister Jul 18, 2018
2f0b21c
lint
thedavidmeister Jul 18, 2018
feddaf5
tests for chain equality
thedavidmeister Jul 18, 2018
0dcc780
lint ns
thedavidmeister Jul 18, 2018
b5f80a1
remove box cloning code for hash tables
thedavidmeister Jul 18, 2018
2d73d3c
lint
thedavidmeister Jul 18, 2018
88bed6c
tests for pair meta cmp
thedavidmeister Jul 18, 2018
992898d
rename open/close to setup/teardown in hashtable
thedavidmeister Jul 18, 2018
7f23066
lint docs
thedavidmeister Jul 18, 2018
82c0a2a
lint
thedavidmeister Jul 18, 2018
c872714
function docs for chain
thedavidmeister Jul 18, 2018
17e87f5
lint fn docs
thedavidmeister Jul 18, 2018
ca8bb27
add operator based tests for pair meta
thedavidmeister Jul 18, 2018
5292cbb
lint
thedavidmeister Jul 18, 2018
ace9f45
Merge commit '77faa09026fde09b1040a809168be742904967f6' into 128-hash…
thedavidmeister Jul 18, 2018
b805c79
run fmt
thedavidmeister Jul 18, 2018
ea17a54
uncomment can_call_commit()
thedavidmeister Jul 18, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ serde_derive = "1.0"
serde_json = { version = "1.0", features = ["preserve_order"] }
multihash = "0.8.0"
rust-base58 = "0.0.4"
bitflags = "1.0"

[dev-dependencies]
wabt = "0.4"
Expand Down
63 changes: 55 additions & 8 deletions core/src/agent/mod.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
pub mod keys;

use agent::keys::Keys;
use chain::{entry::Entry, memory::MemChain, SourceChain};
use chain::Chain;
use hash_table::{entry::Entry, memory::MemTable, pair::Pair};
use state;
use std::sync::{mpsc::Sender, Arc};
use std::{
rc::Rc, sync::{mpsc::Sender, Arc},
};

#[derive(Clone, Debug, PartialEq, Default)]
pub struct AgentState {
keys: Option<Keys>,
source_chain: Option<Box<MemChain>>,
// @TODO how should this work with chains/HTs?
// @see https://github.com/holochain/holochain-rust/issues/137
// @see https://github.com/holochain/holochain-rust/issues/135
top_pair: Option<Pair>,
}

impl AgentState {
pub fn new() -> Self {
/// builds a new, empty AgentState
pub fn new() -> AgentState {
AgentState {
keys: None,
source_chain: Some(Box::new(MemChain::new())),
top_pair: None,
}
}

/// getter for a copy of self.keys
pub fn keys(&self) -> Option<Keys> {
self.keys.clone()
}

/// getter for a copy of self.top_pair
/// should be used with a source chain for validation/safety
pub fn top_pair(&self) -> Option<Pair> {
self.top_pair.clone()
}
}

#[derive(Clone, Debug, PartialEq)]
Expand All @@ -37,13 +55,42 @@ pub fn reduce(
match *agent_action {
Action::Commit(ref entry) => {
// add entry to source chain
if let Some(mut chain) = new_state.source_chain.clone() {
chain.push(entry);
}
// @TODO this does nothing! it isn't exactly clear what it should do either
// @see https://github.com/holochain/holochain-rust/issues/148
let mut chain = Chain::new(Rc::new(MemTable::new()));
chain.push(&entry).unwrap();
}
}
Arc::new(new_state)
}
_ => old_state,
}
}

#[cfg(test)]
pub mod tests {
use super::AgentState;

/// builds a dummy agent state for testing
pub fn test_agent_state() -> AgentState {
AgentState::new()
}

#[test]
/// smoke test for building a new AgentState
fn agent_state_new() {
test_agent_state();
}

#[test]
/// test for the agent state keys getter
fn agent_state_keys() {
assert_eq!(None, test_agent_state().keys());
}

#[test]
/// test for the agent state top pair getter
fn agent_state_top_pair() {
assert_eq!(None, test_agent_state().top_pair());
}
}
Loading